/*
 * The MIT License (MIT)
 *
 * Copyright (c) 2017-2025 Ta4j Organization & respective
 * authors (see AUTHORS)
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy of
 * this software and associated documentation files (the "Software"), to deal in
 * the Software without restriction, including without limitation the rights to
 * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
 * the Software, and to permit persons to whom the Software is furnished to do so,
 * subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in all
 * copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
 * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
 * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
 * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 */
package org.ta4j.core.indicators.pivotpoints;

import static junit.framework.TestCase.assertEquals;
import static org.ta4j.core.TestUtils.assertNumEquals;
import static org.ta4j.core.indicators.pivotpoints.PivotLevel.RESISTANCE_1;
import static org.ta4j.core.indicators.pivotpoints.PivotLevel.RESISTANCE_2;
import static org.ta4j.core.indicators.pivotpoints.PivotLevel.RESISTANCE_3;
import static org.ta4j.core.indicators.pivotpoints.PivotLevel.SUPPORT_1;
import static org.ta4j.core.indicators.pivotpoints.PivotLevel.SUPPORT_2;
import static org.ta4j.core.indicators.pivotpoints.PivotLevel.SUPPORT_3;
import static org.ta4j.core.indicators.pivotpoints.TimeLevel.DAY;
import static org.ta4j.core.indicators.pivotpoints.TimeLevel.MONTH;
import static org.ta4j.core.indicators.pivotpoints.TimeLevel.WEEK;
import static org.ta4j.core.indicators.pivotpoints.TimeLevel.YEAR;
import static org.ta4j.core.num.NaN.NaN;
import static org.junit.Assert.assertFalse;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.ZoneOffset;
import java.time.format.DateTimeFormatter;
import java.util.List;

import org.junit.Before;
import org.junit.Test;
import org.ta4j.core.Bar;
import org.ta4j.core.BarSeries;
import org.ta4j.core.mocks.MockBarSeriesBuilder;
import org.ta4j.core.num.Num;

public class PivotPointIndicatorTest {

    private BarSeries series5Minutes;
    private BarSeries series1Hours;
    private BarSeries series1Days;
    private BarSeries series1Weeks;

    @Before
    public void initDataForDailyBarCount() {
        var rawData5Minutes = """
                2017-09-27,22:00:00,167.86,167.949,167.63,167.68,1746768,0
                2017-09-28,15:35:00,167.94,168.37,167.6,168.24,706119,0
                2017-09-28,15:40:00,168.27,168.399,167.16,167.34,501414,0
                2017-09-28,15:45:00,167.39,168.31,167.39,168.29,332450,0
                2017-09-28,15:50:00,168.2601,168.31,167.76,167.84,253173,0
                2017-09-28,15:55:00,167.83,168.02,167.76,167.9,169481,0
                2017-09-28,16:00:00,167.89,168.25,167.64,168.11,299024,0
                2017-09-28,16:05:00,168.09,168.59,168.09,168.49,260943,0
                2017-09-28,16:10:00,168.46,168.77,168.33,168.675,225866,0
                2017-09-28,16:15:00,168.66,168.66,168.38,168.43,196108,0
                2017-09-28,16:20:00,168.403,168.47,168.09,168.16,152852,0
                2017-09-28,16:25:00,168.16,168.28,168.06,168.1,102641,0
                2017-09-28,16:30:00,168.08,168.72,168.0621,168.6943,224124,0
                2017-09-28,16:35:00,168.66,168.74,168.521,168.5726,159756,0
                2017-09-28,16:40:00,168.56,168.7,168.4502,168.62,120405,0
                2017-09-28,16:45:00,168.6,169.06,168.59,169.02,260050,0
                2017-09-28,16:50:00,169.01,169.0696,168.69,168.8513,189081,0
                2017-09-28,16:55:00,168.82,168.93,168.71,168.9,127425,0
                2017-09-28,17:00:00,168.88,168.9116,168.6,168.6196,127020,0
                2017-09-28,17:05:00,168.6173,168.69,168.48,168.6336,145866,0
                2017-09-28,17:10:00,168.62,168.8,168.59,168.74,132152,0
                2017-09-28,17:15:00,168.76,168.87,168.56,168.57,91621,0
                2017-09-28,17:20:00,168.56,168.71,168.48,168.6901,101503,0
                2017-09-28,17:25:00,168.69,168.74,168.57,168.6212,62758,0
                2017-09-28,17:30:00,168.63,168.7,168.42,168.7,108778,0
                2017-09-28,17:35:00,168.68,168.72,168.46,168.63,106170,0
                2017-09-28,17:40:00,168.62,168.79,168.56,168.64,50262,0
                2017-09-28,17:45:00,168.631,168.71,168.42,168.45,79449,0
                2017-09-28,17:50:00,168.448,168.5,168.27,168.38,196568,0
                2017-09-28,17:55:00,168.36,168.39,168.16,168.212,83478,0
                2017-09-28,18:00:00,168.21,168.25,167.99,168.16,170722,0
                2017-09-28,18:05:00,168.17,168.29,168.01,168.2149,109073,0
                2017-09-28,18:10:00,168.23,168.31,168.1451,168.1668,65361,0
                2017-09-28,18:15:00,168.2,168.27,168.03,168.07,56249,0
                2017-09-28,18:20:00,168.075,168.27,168.075,168.25,95105,0
                2017-09-28,18:25:00,168.2553,168.28,168.17,168.23,41837,0
                2017-09-28,18:30:00,168.23,168.2532,168.02,168.1,54516,0
                2017-09-28,18:35:00,168.11,168.19,168.1,168.17,77834,0
                2017-09-28,18:40:00,168.17,168.1931,168.06,168.06,122010,0
                2017-09-28,18:45:00,168.08,168.08,167.79,167.84,170118,0
                2017-09-28,18:50:00,167.85,168,167.85,167.9814,61922,0
                2017-09-28,18:55:00,168,168.09,167.88,168.09,57266,0
                2017-09-28,19:00:00,168.09,168.19,168.09,168.1,58543,0
                2017-09-28,19:05:00,168.1167,168.19,167.26,167.77,294259,0
                2017-09-28,19:10:00,167.77,167.93,167.63,167.92,134389,0
                2017-09-28,19:15:00,167.925,167.98,167.79,167.97,65208,0
                2017-09-28,19:20:00,167.9602,168.12,167.92,168.008,97565,0
                2017-09-28,19:25:00,168.01,168.29,167.99,168.22,99282,0
                2017-09-28,19:30:00,168.2301,168.28,168.1403,168.24,68625,0
                2017-09-28,19:35:00,168.25,168.28,168.15,168.27,41514,0
                2017-09-28,19:40:00,168.28,168.4526,168.28,168.41,68396,0
                2017-09-28,19:45:00,168.4126,168.49,168.37,168.42,49819,0
                2017-09-28,19:50:00,168.42,168.46,168.3467,168.44,55438,0
                2017-09-28,19:55:00,168.4358,168.55,168.43,168.54,76526,0
                2017-09-28,20:00:00,168.56,168.69,168.53,168.58,87910,0
                2017-09-28,20:05:00,168.58,168.665,168.53,168.6,70156,0
                2017-09-28,20:10:00,168.6,168.6,168.44,168.52,61114,0
                2017-09-28,20:15:00,168.51,168.51,168.365,168.43,58286,0
                2017-09-28,20:20:00,168.3968,168.505,168.34,168.34,53982,0
                2017-09-28,20:25:00,168.35,168.359,168.13,168.13,93947,0
                2017-09-28,20:30:00,168.14,168.3,168.12,168.279,65449,0
                2017-09-28,20:35:00,168.27,168.38,168.185,168.335,49059,0
                2017-09-28,20:40:00,168.33,168.355,168.21,168.24,56022,0
                2017-09-28,20:45:00,168.26,168.37,168.21,168.3632,36538,0
                2017-09-28,20:50:00,168.37,168.42,168.2578,168.2699,58880,0
                2017-09-28,20:55:00,168.29,168.38,168.26,168.37,39166,0
                2017-09-28,21:00:00,168.37,168.55,168.37,168.44,71989,0
                2017-09-28,21:05:00,168.45,168.56,168.39,168.4468,79944,0
                2017-09-28,21:10:00,168.46,168.469,168.291,168.37,57256,0
                2017-09-28,21:15:00,168.3497,168.49,168.33,168.4064,38794,0
                2017-09-28,21:20:00,168.41,168.49,168.4,168.42,31063,0
                2017-09-28,21:25:00,168.436,168.44,168.3,168.34,55086,0
                2017-09-28,21:30:00,168.344,168.36,168.22,168.28,61384,0
                2017-09-28,21:35:00,168.28,168.304,168.14,168.28,108728,0
                2017-09-28,21:40:00,168.28,168.33,168.17,168.25,71156,0
                2017-09-28,21:45:00,168.24,168.3336,168.2,168.29,112327,0
                2017-09-28,21:50:00,168.3,168.33,168,168.2589,159273,0
                2017-09-28,21:55:00,168.24,168.65,168.24,168.635,231928,0
                2017-09-28,22:00:00,168.63,168.82,168.581,168.73,877554,0
                2017-09-29,15:35:00,168.83,169.6,168.81,169.53,623389,0
                2017-09-29,15:40:00,169.51,169.88,169.51,169.75,402657,0
                2017-09-29,15:45:00,169.7999,169.7999,169.43,169.705,318978,0
                2017-09-29,15:50:00,169.734,169.84,169.31,169.795,249071,0
                2017-09-29,15:55:00,169.82,169.89,169.52,169.7,235315,0
                2017-09-29,16:00:00,169.71,169.77,169.4099,169.5,281170,0
                2017-09-29,16:05:00,169.56,169.83,169.38,169.8,326879,0
                2017-09-29,16:10:00,169.79,170.24,169.65,170.2068,413516,0
                2017-09-29,16:15:00,170.23,170.26,169.96,170.16,185665,0
                2017-09-29,16:20:00,170.17,170.23,170.01,170.03,130839,0
                2017-09-29,16:25:00,170.01,170.27,170.01,170.1625,122554,0
                2017-09-29,16:30:00,170.1584,170.87,170.1584,170.58,401063,0
                2017-09-29,16:35:00,170.58,170.83,170.52,170.6,180214,0
                2017-09-29,16:40:00,170.59,170.843,170.56,170.843,136558,0
                2017-09-29,16:45:00,170.85,170.88,170.621,170.71,143770,0
                2017-09-29,16:50:00,170.73,170.74,170.5073,170.5284,117942,0
                2017-09-29,16:55:00,170.53,170.55,170.46,170.481,125567,0
                2017-09-29,17:00:00,170.48,170.74,170.47,170.68,161514,0
                2017-09-29,17:05:00,170.6764,170.7303,170.56,170.56,101555,0
                2017-09-29,17:10:00,170.5668,170.74,170.56,170.5738,88593,0
                2017-09-29,17:15:00,170.57,170.65,170.44,170.448,103141,0
                2017-09-29,17:20:00,170.445,170.86,170.41,170.7852,197559,0
                2017-09-29,17:25:00,170.79,170.96,170.76,170.81,170037,0
                2017-09-29,17:30:00,170.83,170.8404,170.67,170.72,156036,0
                2017-09-29,17:35:00,170.71,170.87,170.67,170.81,108098,0
                2017-09-29,17:40:00,170.81,170.8786,170.6048,170.6288,182604,0
                2017-09-29,17:45:00,170.63,170.64,170.4363,170.4363,101391,0
                2017-09-29,17:50:00,170.4393,170.4757,170.34,170.43,114050,0
                2017-09-29,17:55:00,170.44,170.63,170.44,170.59,93861,0
                2017-09-29,18:00:00,170.59,170.639,170.53,170.58,95934,0
                2017-09-29,18:05:00,170.585,170.69,170.5,170.54,76956,0
                2017-09-29,18:10:00,170.53,170.61,170.5,170.579,63106,0
                2017-09-29,18:15:00,170.55,170.58,170.505,170.54,70915,0
                2017-09-29,18:20:00,170.55,170.7,170.545,170.595,69296,0
                2017-09-29,18:25:00,170.5972,170.66,170.55,170.61,51545,0
                2017-09-29,18:30:00,170.6,170.82,170.58,170.795,80687,0
                2017-09-29,18:35:00,170.7944,170.856,170.79,170.84,91664,0
                2017-09-29,18:40:00,170.8398,170.85,170.74,170.77,76334,0
                2017-09-29,18:45:00,170.7701,171.11,170.74,171.025,378515,0
                2017-09-29,18:50:00,171.021,171.22,171.01,171.1808,222109,0
                2017-09-29,18:55:00,171.195,171.38,171.14,171.37,156630,0
                2017-09-29,19:00:00,171.35,171.39,171.2401,171.35,152538,0
                2017-09-29,19:05:00,171.3468,171.59,171.3468,171.58,166360,0
                2017-09-29,19:10:00,171.5784,171.65,171.5,171.58,116604,0
                2017-09-29,19:15:00,171.58,171.66,171.45,171.55,123553,0
                2017-09-29,19:20:00,171.54,171.55,171.39,171.41,109259,0
                2017-09-29,19:25:00,171.4142,171.5,171.33,171.38,83691,0
                2017-09-29,19:30:00,171.37,171.3901,171.22,171.25,95366,0
                2017-09-29,19:35:00,171.24,171.28,171.22,171.231,100219,0
                2017-09-29,19:40:00,171.23,171.4,171.2298,171.4,93148,0
                2017-09-29,19:45:00,171.38,171.5,171.34,171.39,80264,0
                2017-09-29,19:50:00,171.3942,171.41,171.21,171.22,52943,0
                2017-09-29,19:55:00,171.2265,171.31,171.18,171.3022,75379,0
                2017-09-29,20:00:00,171.31,171.31,171.11,171.2,65708,0
                2017-09-29,20:05:00,171.2042,171.29,171.12,171.13,57920,0
                2017-09-29,20:10:00,171.13,171.13,170.94,171.0021,112416,0
                2017-09-29,20:15:00,171,171,170.88,170.9,46032,0
                2017-09-29,20:20:00,170.8944,170.9604,170.86,170.89,72046,0
                2017-09-29,20:25:00,170.88,170.9353,170.83,170.92,84673,0
                2017-09-29,20:30:00,170.919,170.97,170.85,170.8601,55503,0
                2017-09-29,20:35:00,170.85,170.89,170.7514,170.79,47372,0
                2017-09-29,20:40:00,170.7858,170.7899,170.65,170.72,77312,0
                2017-09-29,20:45:00,170.725,170.74,170.49,170.51,112914,0
                2017-09-29,20:50:00,170.52,170.6,170.5,170.5384,94919,0
                2017-09-29,20:55:00,170.5375,170.74,170.48,170.74,105034,0
                2017-09-29,21:00:00,170.73,170.79,170.64,170.64,102575,0
                2017-09-29,21:05:00,170.64,170.76,170.5901,170.75,64518,0
                2017-09-29,21:10:00,170.74,170.75,170.6,170.6101,103496,0
                2017-09-29,21:15:00,170.61,170.72,170.57,170.6101,167382,0
                2017-09-29,21:20:00,170.6084,170.61,170.3,170.45,110465,0
                2017-09-29,21:25:00,170.44,170.5836,170.4,170.57,146617,0
                2017-09-29,21:30:00,170.58,170.72,170.56,170.56,94241,0
                2017-09-29,21:35:00,170.56,170.56,170.38,170.3879,88600,0
                2017-09-29,21:40:00,170.3807,170.48,170.37,170.42,119247,0
                2017-09-29,21:45:00,170.4166,170.44,170.28,170.3332,140148,0
                2017-09-29,21:50:00,170.32,170.57,170.31,170.41,210241,0
                2017-09-29,21:55:00,170.42,170.97,170.42,170.88,470723,0
                2017-09-29,22:00:00,170.89,170.96,170.75,170.81,529077,0
                2017-10-02,15:35:00,171.39,171.74,171.07,171.55,588294,0
                2017-10-02,15:40:00,171.56,171.87,171.2,171.44,359622,0
                2017-10-02,15:45:00,171.43,171.43,171,171,389084,0
                2017-10-02,15:50:00,171.02,171.0213,170.5,170.57,565126,0
                2017-10-02,15:55:00,170.55,170.66,170.37,170.57,280042,0
                2017-10-02,16:00:00,170.58,170.9,170.43,170.8,239524,0
                2017-10-02,16:05:00,170.77,170.86,170.53,170.84,185532,0
                2017-10-02,16:10:00,170.833,171.0629,170.51,170.6108,318287,0
                2017-10-02,16:15:00,170.61,170.69,170.25,170.515,224911,0
                2017-10-02,16:20:00,170.5146,170.89,170.5,170.63,127456,0
                2017-10-02,16:25:00,170.64,170.77,170.47,170.74,119044,0
                2017-10-02,16:30:00,170.76,170.88,170.67,170.71,88645,0
                2017-10-02,16:35:00,170.7,171.05,170.6,171.05,129027,0
                2017-10-02,16:40:00,171.03,171.03,170.7088,170.769,91230,0
                2017-10-02,16:45:00,170.75,170.81,170.53,170.67,118312,0
                2017-10-02,16:50:00,170.7,170.91,170.685,170.8892,67959,0
                2017-10-02,16:55:00,170.92,170.92,170.62,170.78,57646,0
                2017-10-02,17:00:00,170.8,170.88,170.685,170.73,45319,0
                2017-10-02,17:05:00,170.73,170.79,170.5701,170.65,99757,0
                2017-10-02,17:10:00,170.66,170.71,170.58,170.62,53827,0
                2017-10-02,17:15:00,170.62,170.7305,170.54,170.6805,87297,0
                2017-10-02,17:20:00,170.67,170.915,170.59,170.63,92718,0
                2017-10-02,17:25:00,170.6184,170.69,170.57,170.65,56440,0
                2017-10-02,17:30:00,170.6406,170.66,170.4684,170.55,126303,0
                2017-10-02,17:35:00,170.559,170.559,170.11,170.1489,174048,0
                2017-10-02,17:40:00,170.1445,170.15,169.89,170.0316,281141,0
                2017-10-02,17:45:00,170.03,170.07,169.63,169.71,205253,0
                2017-10-02,17:50:00,169.72,169.75,169.44,169.6407,163311,0
                2017-10-02,17:55:00,169.645,169.834,169.47,169.83,170545,0
                2017-10-02,18:00:00,169.85,169.88,169.1,169.1827,206384,0
                2017-10-02,18:05:00,169.18,169.1827,168.75,169.08,274548,0
                2017-10-02,18:10:00,169.08,169.3,169.02,169.24,142191,0
                2017-10-02,18:15:00,169.2646,169.28,169.05,169.13,159430,0
                2017-10-02,18:20:00,169.1184,169.39,169.06,169.39,112785,0
                2017-10-02,18:25:00,169.3761,169.668,169.3584,169.57,139816,0
                2017-10-02,18:30:00,169.58,169.7,169.53,169.57,75071,0
                2017-10-02,18:35:00,169.56,169.66,169.4226,169.51,87149,0
                2017-10-02,18:40:00,169.51,169.5689,169.44,169.44,81034,0
                2017-10-02,18:45:00,169.4425,169.495,169.33,169.495,102046,0
                2017-10-02,18:50:00,169.49,169.56,169.42,169.42,93721,0
                2017-10-02,18:55:00,169.42,169.5,169.39,169.4276,62662,0
                2017-10-02,19:00:00,169.4163,169.63,169.4163,169.59,62796,0
                2017-10-02,19:05:00,169.59,169.77,169.47,169.7149,99259,0
                2017-10-02,19:10:00,169.71,169.77,169.5946,169.6,58483,0
                2017-10-02,19:15:00,169.61,169.75,169.5,169.72,56775,0
                2017-10-02,19:20:00,169.73,169.85,169.6621,169.79,59568,0
                2017-10-02,19:25:00,169.8,169.8856,169.71,169.8109,59454,0
                2017-10-02,19:30:00,169.81,169.8294,169.7,169.78,60161,0
                2017-10-02,19:35:00,169.78,169.83,169.6314,169.72,51695,0
                2017-10-02,19:40:00,169.72,169.8,169.49,169.6394,92280,0
                2017-10-02,19:45:00,169.65,169.65,169.47,169.5,84189,0
                2017-10-02,19:50:00,169.511,169.6999,169.511,169.6404,52544,0
                2017-10-02,19:55:00,169.65,169.68,169.62,169.67,45082,0
                2017-10-02,20:00:00,169.6684,169.7,169.52,169.65,58666,0
                2017-10-02,20:05:00,169.65,169.73,169.57,169.66,62389,0
                2017-10-02,20:10:00,169.66,169.72,169.6,169.72,47445,0
                2017-10-02,20:15:00,169.73,169.73,169.6,169.64,64938,0
                2017-10-02,20:20:00,169.6453,169.65,169.53,169.62,58709,0
                2017-10-02,20:25:00,169.61,169.71,169.55,169.65,62378,0
                2017-10-02,20:30:00,169.6514,170.14,169.64,170.115,232773,0
                2017-10-02,20:35:00,170.11,170.33,170.1,170.302,139619,0
                2017-10-02,20:40:00,170.3,170.312,170.16,170.285,86557,0
                2017-10-02,20:45:00,170.285,170.32,170.1,170.14,76256,0
                2017-10-02,20:50:00,170.13,170.18,169.88,169.94,144037,0
                2017-10-02,20:55:00,169.9406,170.02,169.88,169.9031,73110,0
                2017-10-02,21:00:00,169.91,169.98,169.77,169.83,96418,0
                2017-10-02,21:05:00,169.82,169.98,169.7,169.8002,130333,0
                2017-10-02,21:10:00,169.8,169.82,169.65,169.7387,86945,0
                2017-10-02,21:15:00,169.72,169.78,169.62,169.63,91854,0
                2017-10-02,21:20:00,169.63,169.7,169.56,169.68,87127,0
                2017-10-02,21:25:00,169.67,169.84,169.635,169.65,87038,0
                2017-10-02,21:30:00,169.65,169.7553,169.65,169.65,74510,0
                2017-10-02,21:35:00,169.64,169.745,169.5276,169.55,102864,0
                2017-10-02,21:40:00,169.54,169.65,169.53,169.62,112944,0
                2017-10-02,21:45:00,169.6102,169.63,169.38,169.4851,135767,0
                2017-10-02,21:50:00,169.49,169.57,169.36,169.54,120950,0
                2017-10-02,21:55:00,169.54,169.82,169.25,169.62,354984,0
                2017-10-02,22:00:00,169.6207,169.67,169.35,169.47,1015547,0
                2017-10-03,15:35:00,169.3,169.74,169.2,169.6352,406843,0
                2017-10-03,15:40:00,169.62,170.44,169.51,170.3745,378048,0
                2017-10-03,15:45:00,170.3805,170.47,170.01,170.02,254547,0
                2017-10-03,15:50:00,170.058,170.72,170.02,170.64,250809,0
                2017-10-03,15:55:00,170.65,170.66,170.332,170.44,158609,0
                2017-10-03,16:00:00,170.43,170.73,170.425,170.59,136805,0
                2017-10-03,16:05:00,170.59,170.7,170.33,170.555,97150,0
                2017-10-03,16:10:00,170.56,170.585,170.1,170.285,139735,0
                2017-10-03,16:15:00,170.29,170.35,169.65,169.67,216528,0
                2017-10-03,16:20:00,169.69,169.95,169.44,169.9117,283003,0
                2017-10-03,16:25:00,169.911,170.09,169.72,170,120083,0
                2017-10-03,16:30:00,169.99,170.14,169.92,170.053,110589,0
                2017-10-03,16:35:00,170.05,170.32,169.85,170.2,181088,0
                2017-10-03,16:40:00,170.19,170.47,170.1445,170.47,118138,0
                2017-10-03,16:45:00,170.47,170.49,170.18,170.183,55228,0
                2017-10-03,16:50:00,170.18,170.34,170.11,170.24,64900,0
                2017-10-03,16:55:00,170.25,170.39,170.11,170.21,72447,0
                2017-10-03,17:00:00,170.2078,170.46,170.1684,170.3365,87446,0
                2017-10-03,17:05:00,170.32,170.46,170.31,170.35,54672,0
                2017-10-03,17:10:00,170.35,170.47,170.33,170.37,79862,0
                2017-10-03,17:15:00,170.38,170.43,170.27,170.36,70582,0
                2017-10-03,17:20:00,170.3601,170.47,170.342,170.47,48196,0
                2017-10-03,17:25:00,170.47,170.578,170.4,170.47,54960,0
                2017-10-03,17:30:00,170.47,170.48,170.1999,170.219,59327,0
                2017-10-03,17:35:00,170.22,170.3624,170.18,170.29,52495,0
                2017-10-03,17:40:00,170.28,170.289,170.1,170.175,58176,0
                2017-10-03,17:45:00,170.16,170.22,170.0701,170.18,41250,0
                2017-10-03,17:50:00,170.17,170.26,170.09,170.26,37439,0
                2017-10-03,17:55:00,170.25,170.25,170.09,170.16,36528,0
                2017-10-03,18:00:00,170.1559,170.1559,169.97,170.0568,57627,0
                2017-10-03,18:05:00,170.06,170.14,170.02,170.06,33036,0
                2017-10-03,18:10:00,170.051,170.09,169.95,170.08,42033,0
                2017-10-03,18:15:00,170.09,170.2497,170.06,170.18,44289,0
                2017-10-03,18:20:00,170.18,170.265,170.1,170.12,42199,0
                2017-10-03,18:25:00,170.11,170.13,170,170.09,127542,0
                2017-10-03,18:30:00,170.09,170.14,170.02,170.03,45278,0
                2017-10-03,18:35:00,170.03,170.11,170,170.1016,77518,0
                2017-10-03,18:40:00,170.1,170.13,170,170.0268,43636,0
                2017-10-03,18:45:00,170.03,170.04,169.9,169.93,75863,0
                2017-10-03,18:50:00,169.93,170.03,169.82,169.85,71378,0
                2017-10-03,18:55:00,169.85,170,169.84,169.9252,51154,0
                2017-10-03,19:00:00,169.93,169.98,169.9,169.98,21103,0
                2017-10-03,19:05:00,169.9769,170.09,169.91,170.09,56346,0
                2017-10-03,19:10:00,170.09,170.1,169.93,169.935,48134,0
                2017-10-03,19:15:00,169.94,170.05,169.94,170.0301,24779,0
                2017-10-03,19:20:00,170.0335,170.0335,169.8945,169.934,28837,0
                2017-10-03,19:25:00,169.92,170.03,169.88,169.9234,55398,0
                2017-10-03,19:30:00,169.91,170.02,169.9,169.94,56641,0
                2017-10-03,19:35:00,169.9366,169.97,169.86,169.88,46685,0
                2017-10-03,19:40:00,169.86,170.0251,169.85,170,44470,0
                2017-10-03,19:45:00,170,170.01,169.83,169.91,70571,0
                2017-10-03,19:50:00,169.91,169.9872,169.91,169.97,24873,0
                2017-10-03,19:55:00,169.98,170.03,169.97,170.0165,22077,0
                2017-10-03,20:00:00,170.0209,170.03,169.93,169.989,38646,0
                2017-10-03,20:05:00,169.97,170.1,169.96,170.0701,41230,0
                2017-10-03,20:10:00,170.08,170.09,170.01,170.0343,43049,0
                2017-10-03,20:15:00,170.04,170.17,170.04,170.155,40711,0
                2017-10-03,20:20:00,170.15,170.255,170.13,170.19,53786,0
                2017-10-03,20:25:00,170.18,170.25,170.15,170.17,37430,0
                2017-10-03,20:30:00,170.16,170.16,170.0699,170.11,25705,0
                2017-10-03,20:35:00,170.11,170.14,170.06,170.09,38273,0
                2017-10-03,20:40:00,170.1,170.1197,170,170.05,35705,0
                2017-10-03,20:45:00,170.0451,170.09,170.02,170.04,22701,0
                2017-10-03,20:50:00,170.03,170.11,169.97,170.05,48164,0
                2017-10-03,20:55:00,170.055,170.1389,170.04,170.06,39045,0
                2017-10-03,21:00:00,170.07,170.14,170.0445,170.08,26367,0
                2017-10-03,21:05:00,170.087,170.1,169.95,169.98,37274,0
                2017-10-03,21:10:00,169.97,169.98,169.87,169.9155,60362,0
                2017-10-03,21:15:00,169.9199,170.01,169.85,170,80632,0
                2017-10-03,21:20:00,170,170.02,169.9167,169.99,67873,0
                2017-10-03,21:25:00,169.99,170.1,169.96,169.96,35384,0
                2017-10-03,21:30:00,169.96,170.04,169.86,169.98,50925,0
                2017-10-03,21:35:00,169.985,170.04,169.93,169.97,67340,0
                2017-10-03,21:40:00,169.98,170.16,169.92,170.16,121267,0
                2017-10-03,21:45:00,170.17,170.17,169.99,170.04,73965,0
                2017-10-03,21:50:00,170.0498,170.05,169.87,169.8933,92198,0
                2017-10-03,21:55:00,169.9,169.95,169.82,169.91,149032,0
                2017-10-03,22:00:00,169.9154,170,169.76,169.96,743526,0
                2017-10-04,15:35:00,169.83,170.24,169.52,169.975,398157,0
                2017-10-04,15:40:00,169.99,170.1218,169.53,169.671,299473,0
                2017-10-04,15:45:00,169.685,169.92,169.12,169.34,280530,0
                2017-10-04,15:50:00,169.35,169.58,169.19,169.53,173560,0
                2017-10-04,15:55:00,169.5599,169.85,169.52,169.75,152409,0
                2017-10-04,16:00:00,169.74,169.9,169.68,169.786,97553,0
                2017-10-04,16:05:00,169.785,169.98,169.6001,169.9364,132937,0
                2017-10-04,16:10:00,169.935,170.1,169.83,170.0978,184817,0
                2017-10-04,16:15:00,170.09,170.52,170.07,170.46,311474,0
                2017-10-04,16:20:00,170.46,170.65,170.46,170.5552,142525,0
                2017-10-04,16:25:00,170.5557,170.6,170.43,170.56,105005,0
                2017-10-04,16:30:00,170.57,170.6499,170.28,170.29,83623,0
                2017-10-04,16:35:00,170.29,170.41,170.03,170.16,107134,0
                2017-10-04,16:40:00,170.15,170.17,170.02,170.07,71016,0
                2017-10-04,16:45:00,170.05,170.1599,169.9,170.14,98949,0
                2017-10-04,16:50:00,170.1293,170.25,170.05,170.1565,57149,0
                2017-10-04,16:55:00,170.19,170.28,170.14,170.2767,41865,0
                2017-10-04,17:00:00,170.275,170.45,170.27,170.359,89708,0
                2017-10-04,17:05:00,170.36,170.5,170.36,170.425,90904,0
                2017-10-04,17:10:00,170.4158,170.53,170.28,170.32,85245,0
                2017-10-04,17:15:00,170.32,170.36,170.19,170.19,35387,0
                2017-10-04,17:20:00,170.2068,170.28,170.1601,170.23,49177,0
                2017-10-04,17:25:00,170.23,170.28,170.18,170.27,68875,0
                2017-10-04,17:30:00,170.27,170.486,170.18,170.48,62464,0
                2017-10-04,17:35:00,170.4799,170.53,170.29,170.3959,62946,0
                2017-10-04,17:40:00,170.4,170.67,170.4,170.47,299961,0
                2017-10-04,17:45:00,170.45,170.45,170.2401,170.285,52537,0
                2017-10-04,17:50:00,170.29,170.32,170.22,170.28,33454,0
                2017-10-04,17:55:00,170.27,170.37,170.11,170.1332,87204,0
                2017-10-04,18:00:00,170.12,170.18,170.0277,170.09,82042,0
                2017-10-04,18:05:00,170.0844,170.11,169.98,170.06,47941,0
                2017-10-04,18:10:00,170.04,170.15,170.016,170.13,41231,0
                2017-10-04,18:15:00,170.12,170.2,170.1,170.15,30757,0
                2017-10-04,18:20:00,170.1709,170.54,170.15,170.37,107087,0
                2017-10-04,18:25:00,170.38,170.46,170.27,170.42,53164,0
                2017-10-04,18:30:00,170.43,170.4391,170.33,170.3617,16467,0
                2017-10-04,18:35:00,170.38,170.38,170.2004,170.2095,48056,0
                2017-10-04,18:40:00,170.22,170.31,170.14,170.175,42391,0
                2017-10-04,18:45:00,170.169,170.2,170.08,170.199,30249,0
                2017-10-04,18:50:00,170.17,170.17,169.99,170.0399,90641,0
                2017-10-04,18:55:00,170.035,170.17,170.02,170.17,42272,0
                2017-10-04,19:00:00,170.17,170.3011,169.9,169.95,190402,0
                2017-10-04,19:05:00,169.95,170.0011,169.72,169.8,185279,0
                2017-10-04,19:10:00,169.7912,169.82,169.7,169.7,87907,0
                2017-10-04,19:15:00,169.7084,169.76,169.5,169.5497,150575,0
                2017-10-04,19:20:00,169.55,169.55,169.3,169.48,165884,0
                2017-10-04,19:25:00,169.4624,169.5492,169.41,169.5145,93177,0
                2017-10-04,19:30:00,169.5147,169.59,169.45,169.48,68605,0
                2017-10-04,19:35:00,169.4715,169.48,169.25,169.3342,163891,0
                2017-10-04,19:40:00,169.335,169.335,168.89,169.0541,397847,0
                2017-10-04,19:45:00,169.0541,169.1313,168.95,169.1313,118981,0
                2017-10-04,19:50:00,169.1356,169.17,169.05,169.13,107858,0
                2017-10-04,19:55:00,169.15,169.4,169.14,169.29,150707,0
                2017-10-04,20:00:00,169.2944,169.37,169.19,169.31,74009,0
                2017-10-04,20:05:00,169.31,169.42,169.27,169.3,149683,0
                2017-10-04,20:10:00,169.29,169.49,169.29,169.35,65945,0
                2017-10-04,20:15:00,169.34,169.36,169.23,169.2744,51156,0
                2017-10-04,20:20:00,169.28,169.297,169.1732,169.285,33019,0
                2017-10-04,20:25:00,169.28,169.3399,169.23,169.24,34718,0
                2017-10-04,20:30:00,169.2344,169.27,169.14,169.2,175020,0
                2017-10-04,20:35:00,169.2056,169.25,169.08,169.11,135676,0
                2017-10-04,20:40:00,169.1,169.16,169.065,169.09,82331,0
                2017-10-04,20:45:00,169.09,169.18,169.05,169.15,112675,0
                2017-10-04,20:50:00,169.1401,169.16,169.13,169.15,39535,0
                2017-10-04,20:55:00,169.15,169.255,169.14,169.21,88144,0
                2017-10-04,21:00:00,169.22,169.28,169.2,169.22,55237,0
                2017-10-04,21:05:00,169.219,169.24,169.0901,169.17,76080,0
                2017-10-04,21:10:00,169.1819,169.24,169.13,169.23,55788,0
                2017-10-04,21:15:00,169.24,169.34,169.2,169.305,83015,0
                2017-10-04,21:20:00,169.305,169.43,169.29,169.37,114681,0
                2017-10-04,21:25:00,169.39,169.4,169.32,169.34,69299,0
                2017-10-04,21:30:00,169.33,169.35,169.21,169.21,88829,0
                2017-10-04,21:35:00,169.21,169.25,169.12,169.23,132991,0
                2017-10-04,21:40:00,169.22,169.2961,169.14,169.18,104071,0
                2017-10-04,21:45:00,169.18,169.19,169.025,169.1,120937,0
                2017-10-04,21:50:00,169.09,169.12,168.92,168.99,264181,0
                2017-10-04,21:55:00,169,169,168.32,168.36,567124,0
                2017-10-04,22:00:00,168.3593,168.48,168.29,168.42,1263104,0"
                2017-10-05,15:35:00,169.18,169.75,169.17,169.4,551260,0
                2017-10-05,15:40:00,169.44,169.66,169.3001,169.33,300542,0
                2017-10-05,15:45:00,169.33,169.615,169.05,169.43,446135,0
                2017-10-05,15:50:00,169.43,169.66,169.43,169.48,175125,0
                2017-10-05,15:55:00,169.5069,169.65,169.02,169.22,218871,0
                2017-10-05,16:00:00,169.23,169.28,168.76,168.82,260499,0
                2017-10-05,16:05:00,168.79,169.07,168.77,168.87,246255,0
                2017-10-05,16:10:00,168.87,169.08,168.83,168.91,283385,0
                2017-10-05,16:15:00,168.9,168.9899,168.83,168.9,149244,0
                2017-10-05,16:20:00,168.9,169.37,168.87,169.338,250532,0
                2017-10-05,16:25:00,169.31,169.5,169.2903,169.38,136187,0
                2017-10-05,16:30:00,169.371,169.63,169.34,169.36,239973,0
                2017-10-05,16:35:00,169.35,169.38,168.62,168.8495,271145,0
                2017-10-05,16:40:00,168.86,169.157,168.86,169.12,116436,0
                2017-10-05,16:45:00,169.12,169.25,168.97,169.075,116907,0
                2017-10-05,16:50:00,169.0769,169.12,168.8,168.83,125154,0
                2017-10-05,16:55:00,168.83,168.87,168.62,168.66,250228,0
                2017-10-05,17:00:00,168.65,168.831,168.6,168.66,131683,0
                2017-10-05,17:05:00,168.67,168.85,168.67,168.78,77072,0
                2017-10-05,17:10:00,168.781,168.89,168.65,168.68,191292,0
                2017-10-05,17:15:00,168.69,168.9,168.69,168.81,55178,0
                2017-10-05,17:20:00,168.82,168.825,168.71,168.75,51215,0
                2017-10-05,17:25:00,168.75,168.918,168.75,168.9,66924,0
                2017-10-05,17:30:00,168.89,169.07,168.89,169.03,129045,0
                2017-10-05,17:35:00,169.03,169.24,168.99,169.24,103682,0
                2017-10-05,17:40:00,169.235,169.25,169,169.065,72765,0
                2017-10-05,17:45:00,169.08,169.21,169.06,169.1,52377,0
                2017-10-05,17:50:00,169.09,169.1,168.81,168.84,97458,0
                2017-10-05,17:55:00,168.84,168.8709,168.7,168.79,96050,0
                2017-10-05,18:00:00,168.79,168.97,168.75,168.935,57725,0
                2017-10-05,18:05:00,168.92,169.09,168.9199,168.99,58552,0
                2017-10-05,18:10:00,168.99,169.04,168.93,168.9438,33871,0
                2017-10-05,18:15:00,168.95,169.25,168.94,169.21,92189,0
                2017-10-05,18:20:00,169.21,169.54,169.21,169.52,164189,0
                2017-10-05,18:25:00,169.53,169.99,169.53,169.97,319811,0
                2017-10-05,18:30:00,169.955,170.34,169.93,170.2998,425631,0
                2017-10-05,18:35:00,170.3,170.49,170.14,170.2,244958,0
                2017-10-05,18:40:00,170.2,170.66,170.131,170.6,229089,0
                2017-10-05,18:45:00,170.59,170.63,170.34,170.51,145818,0
                2017-10-05,18:50:00,170.5127,170.75,170.5044,170.7,199695,0
                2017-10-05,18:55:00,170.68,170.7,170.591,170.664,87695,0
                2017-10-05,19:00:00,170.65,170.7,170.54,170.6,132210,0
                2017-10-05,19:05:00,170.59,170.72,170.52,170.6907,84610,0
                2017-10-05,19:10:00,170.6799,170.7,170.55,170.64,59561,0
                2017-10-05,19:15:00,170.64,170.65,170.45,170.58,74779,0
                2017-10-05,19:20:00,170.59,170.6,170.41,170.5264,73591,0
                2017-10-05,19:25:00,170.53,170.62,170.44,170.52,48826,0
                2017-10-05,19:30:00,170.52,170.63,170.44,170.6,85789,0
                2017-10-05,19:35:00,170.5965,170.62,170.38,170.6,109223,0
                2017-10-05,19:40:00,170.6,170.82,170.52,170.7848,139266,0
                2017-10-05,19:45:00,170.7776,170.8,170.61,170.72,79229,0
                2017-10-05,19:50:00,170.7037,170.79,170.6701,170.73,77545,0
                2017-10-05,19:55:00,170.74,170.88,170.74,170.8,122197,0
                2017-10-05,20:00:00,170.805,170.89,170.57,170.64,163130,0
                2017-10-05,20:05:00,170.63,170.69,170.53,170.54,83694,0
                2017-10-05,20:10:00,170.54,170.63,170.53,170.5502,49975,0
                2017-10-05,20:15:00,170.55,170.59,170.5,170.5667,35498,0
                2017-10-05,20:20:00,170.575,170.66,170.56,170.6,73553,0
                2017-10-05,20:25:00,170.59,170.63,170.52,170.55,53525,0
                2017-10-05,20:30:00,170.555,170.59,170.45,170.4936,39509,0
                2017-10-05,20:35:00,170.5032,170.615,170.49,170.5708,69477,0
                2017-10-05,20:40:00,170.5751,170.62,170.51,170.57,67598,0
                2017-10-05,20:45:00,170.5825,170.69,170.55,170.59,106098,0
                2017-10-05,20:50:00,170.6,170.64,170.52,170.56,47525,0
                2017-10-05,20:55:00,170.5615,170.62,170.53,170.58,45716,0
                2017-10-05,21:00:00,170.599,170.9,170.52,170.76,97779,0
                2017-10-05,21:05:00,170.76,171,170.75,170.976,224416,0
                2017-10-05,21:10:00,170.98,171,170.77,170.84,135360,0
                2017-10-05,21:15:00,170.83,170.86,170.75,170.77,70224,0
                2017-10-05,21:20:00,170.783,170.89,170.75,170.885,69051,0
                2017-10-05,21:25:00,170.8899,171,170.84,170.89,110395,0
                2017-10-05,21:30:00,170.9,170.99,170.83,170.83,149043,0
                2017-10-05,21:35:00,170.83,171,170.81,170.96,119791,0
                2017-10-05,21:40:00,170.97,171.05,170.81,170.985,251145,0
                2017-10-05,21:45:00,170.99,171.1,170.9795,171.08,143574,0
                2017-10-05,21:50:00,171.09,171.17,170.98,171.05,195975,0
                2017-10-05,21:55:00,171.04,171.15,170.8,171.131,433457,0
                2017-10-05,22:00:00,171.14,171.31,171.13,171.24,1128343,0
                2017-10-06,15:35:00,170.25,170.31,169.75,170.1,664149,0
                2017-10-06,15:40:00,170.08,170.42,169.81,170.25,320783,0
                2017-10-06,15:45:00,170.25,170.86,170.1301,170.775,324838,0
                2017-10-06,15:50:00,170.77,170.99,170.611,170.65,336886,0
                2017-10-06,15:55:00,170.65,170.72,170.3,170.31,157502,0
                2017-10-06,16:00:00,170.31,170.5,170.25,170.495,136683,0
                2017-10-06,16:05:00,170.49,170.76,170.45,170.7,209150,0
                2017-10-06,16:10:00,170.67,170.88,170.57,170.75,166652,0
                2017-10-06,16:15:00,170.7454,170.8,170.56,170.56,184889,0
                2017-10-06,16:20:00,170.56,170.6109,170.39,170.5,117913,0
                2017-10-06,16:25:00,170.5,170.6,170.35,170.57,98916,0
                2017-10-06,16:30:00,170.5734,170.5734,170.34,170.44,125507,0
                2017-10-06,16:35:00,170.45,170.4903,170.36,170.44,96602,0
                2017-10-06,16:40:00,170.44,170.5,170.27,170.43,148571,0
                2017-10-06,16:45:00,170.44,170.475,170.31,170.34,84227,0
                2017-10-06,16:50:00,170.35,170.55,170.34,170.474,87117,0
                2017-10-06,16:55:00,170.46,170.54,170.29,170.32,115809,0
                2017-10-06,17:00:00,170.35,170.35,170.11,170.2599,183249,0
                2017-10-06,17:05:00,170.26,170.47,170.26,170.31,90236,0
                2017-10-06,17:10:00,170.31,170.4272,170.27,170.29,50300,0
                2017-10-06,17:15:00,170.32,170.4,170.3,170.385,54053,0
                2017-10-06,17:20:00,170.39,170.71,170.37,170.66,143121,0
                2017-10-06,17:25:00,170.65,170.71,170.5475,170.7,106767,0
                2017-10-06,17:30:00,170.69,170.85,170.6801,170.8,76303,0
                2017-10-06,17:35:00,170.81,170.85,170.74,170.83,68554,0
                2017-10-06,17:40:00,170.83,170.86,170.66,170.7,93086,0
                2017-10-06,17:45:00,170.695,170.78,170.6,170.7,67186,0
                2017-10-06,17:50:00,170.73,171.05,170.7217,170.99,124157,0
                2017-10-06,17:55:00,170.999,171.1,170.99,171.06,74128,0
                2017-10-06,18:00:00,171.0691,171.351,171.01,171.3,172326,0
                2017-10-06,18:05:00,171.319,171.4,171.13,171.33,172606,0
                2017-10-06,18:10:00,171.36,171.54,171.3,171.4399,147101,0
                2017-10-06,18:15:00,171.4391,171.5,171.26,171.3664,119360,0
                2017-10-06,18:20:00,171.363,171.45,171.32,171.44,54723,0
                2017-10-06,18:25:00,171.445,171.58,171.35,171.57,88315,0
                2017-10-06,18:30:00,171.57,171.78,171.54,171.7639,123191,0
                2017-10-06,18:35:00,171.7623,172.14,171.75,172.08,408140,0
                2017-10-06,18:40:00,172.09,172.25,171.985,172.22,140686,0
                2017-10-06,18:45:00,172.22,172.28,172.04,172.23,91064,0
                2017-10-06,18:50:00,172.22,172.2345,172.13,172.17,188036,0
                2017-10-06,18:55:00,172.1601,172.18,172.05,172.17,112332,0
                2017-10-06,19:00:00,172.1762,172.19,171.99,172.05,131256,0
                2017-10-06,19:05:00,172.0498,172.2,171.8,171.8,219040,0
                2017-10-06,19:10:00,171.81,171.88,171.62,171.77,122858,0
                2017-10-06,19:15:00,171.77,171.84,171.57,171.62,136296,0
                2017-10-06,19:20:00,171.6,171.68,171.56,171.67,108984,0
                2017-10-06,19:25:00,171.67,171.88,171.58,171.8521,127761,0
                2017-10-06,19:30:00,171.8514,171.93,171.64,171.7,95688,0
                2017-10-06,19:35:00,171.72,171.78,171.51,171.53,71837,0
                2017-10-06,19:40:00,171.54,171.61,171.4391,171.61,89620,0
                2017-10-06,19:45:00,171.6199,171.7876,171.56,171.76,72493,0
                2017-10-06,19:50:00,171.76,171.78,171.65,171.65,35393,0
                2017-10-06,19:55:00,171.68,171.7,171.62,171.69,38159,0
                2017-10-06,20:00:00,171.67,171.71,171.62,171.69,29785,0
                2017-10-06,20:05:00,171.68,171.685,171.56,171.57,30352,0
                2017-10-06,20:10:00,171.58,171.7099,171.55,171.67,39764,0
                2017-10-06,20:15:00,171.6601,171.6601,171.52,171.57,51418,0
                2017-10-06,20:20:00,171.5614,171.63,171.54,171.6,49072,0
                2017-10-06,20:25:00,171.5891,171.63,171.54,171.5999,39779,0
                2017-10-06,20:30:00,171.59,171.59,171.36,171.41,70373,0
                2017-10-06,20:35:00,171.44,171.52,171.42,171.52,44849,0
                2017-10-06,20:40:00,171.525,171.57,171.44,171.45,45171,0
                2017-10-06,20:45:00,171.44,171.55,171.41,171.51,38605,0
                2017-10-06,20:50:00,171.501,171.6284,171.501,171.54,57509,0
                2017-10-06,20:55:00,171.54,171.66,171.51,171.63,47831,0
                2017-10-06,21:00:00,171.64,171.71,171.599,171.6728,54993,0
                2017-10-06,21:05:00,171.67,171.75,171.6301,171.72,57250,0
                2017-10-06,21:10:00,171.72,171.79,171.71,171.75,62189,0
                2017-10-06,21:15:00,171.7454,171.77,171.67,171.76,60708,0
                2017-10-06,21:20:00,171.76,171.77,171.55,171.6,91057,0
                2017-10-06,21:25:00,171.5886,171.81,171.5886,171.8013,69765,0
                2017-10-06,21:30:00,171.81,171.82,171.62,171.74,85199,0
                2017-10-06,21:35:00,171.74,171.78,171.66,171.67,49544,0
                2017-10-06,21:40:00,171.6636,171.8,171.63,171.79,64271,0
                2017-10-06,21:45:00,171.8,171.99,171.79,171.965,156700,0
                2017-10-06,21:50:00,171.96,172.1,171.9,171.93,270150,0
                2017-10-06,21:55:00,171.95,172.25,171.95,172.24,287810,0
                2017-10-06,22:00:00,172.24,172.37,172.16,172.23,1062537,0
                """;

        var dtf = DateTimeFormatter.ofPattern("yyyy-MM-dd H:m:s");
        var zone = ZoneId.of("America/Los_Angeles");
        series5Minutes = new MockBarSeriesBuilder().withName("FB_5_minutes").build();
        rawData5Minutes.lines().forEach(aDataLine -> {
            var barData = aDataLine.split(",");
            var local = LocalDateTime.parse(barData[0] + " " + barData[1], dtf);
            var date = local.atZone(zone).toInstant();
            var open = Double.parseDouble(barData[2]);
            var high = Double.parseDouble(barData[3]);
            var low = Double.parseDouble(barData[4]);
            var close = Double.parseDouble(barData[5]);
            var volume = Double.parseDouble(barData[6]);
            series5Minutes.barBuilder()
                    .endTime(date)
                    .openPrice(open)
                    .closePrice(close)
                    .highPrice(high)
                    .lowPrice(low)
                    .volume(volume)
                    .add();
        });
    }

    @Before
    public void initDataForWeeklyBarCount() {
        var rawData1Hours = """
                2017-09-01,16:00:00,172.4,172.55,171.58,171.8,2204582,0
                2017-09-01,17:00:00,171.79,172.49,171.31,172.43,1870246,0
                2017-09-01,18:00:00,172.42,172.84,172.24,172.74,1264679,0
                2017-09-01,19:00:00,172.74,172.915,172.34,172.37,987869,0
                2017-09-01,20:00:00,172.37,172.4803,171.995,172.2189,1159335,0
                2017-09-01,21:00:00,172.2174,172.3593,171.85,172.0151,830724,0
                2017-09-01,22:00:00,172.03,172.39,171.92,172.02,1777758,0
                2017-09-05,16:00:00,171.27,172.22,170.7301,172.08,1685421,0
                2017-09-05,17:00:00,172.0731,172.3875,171.36,171.51,1879301,0
                2017-09-05,18:00:00,171.49,171.5,170.95,171.21,1231823,0
                2017-09-05,19:00:00,171.19,171.19,169.88,170.319,1724213,0
                2017-09-05,20:00:00,170.27,170.47,169.55,170.45,1321590,0
                2017-09-05,21:00:00,170.43,170.9,170.21,170.6003,1174472,0
                2017-09-05,22:00:00,170.61,170.95,170.43,170.72,2004332,0
                2017-09-06,16:00:00,170.91,171.49,170.76,171.25,1420276,0
                2017-09-06,17:00:00,171.25,171.25,169.65,170.31,2110723,0
                2017-09-06,18:00:00,170.34,170.64,169.57,170.52,1391833,0
                2017-09-06,19:00:00,170.515,171.44,170.45,171.4211,1314133,0
                2017-09-06,20:00:00,171.43,171.64,171.28,171.37,1127506,0
                2017-09-06,21:00:00,171.38,172.04,171.33,171.98,1654536,0
                2017-09-06,22:00:00,171.98,172.48,171.84,172.09,2815393,0
                2017-09-07,16:00:00,171.94,172.05,170.57,170.64,2387691,0
                2017-09-07,17:00:00,170.65,171.18,170.27,171.015,3142555,0
                2017-09-07,18:00:00,171.03,172.49,171.03,172.36,2440694,0
                2017-09-07,19:00:00,172.355,172.73,171.91,172.5,2437801,0
                2017-09-07,20:00:00,172.48,172.87,172.299,172.78,1410186,0
                2017-09-07,21:00:00,172.77,172.99,172.63,172.94,1279331,0
                2017-09-07,22:00:00,172.94,173.3067,172.72,173.21,2543650,0
                2017-09-08,16:00:00,173.09,173.49,172.69,172.991,1459655,0
                2017-09-08,17:00:00,173.02,173.1,172.25,172.66,1354956,0
                2017-09-08,18:00:00,172.66,172.95,172.14,172.21,1075148,0
                2017-09-08,19:00:00,172.22,172.35,171.71,171.879,1197265,0
                2017-09-08,20:00:00,171.88,172.13,171.42,171.435,959896,0
                2017-09-08,21:00:00,171.44,171.51,171.11,171.24,893674,0
                2017-09-08,22:00:00,171.27,171.35,170.8,170.95,1654448,0
                2017-09-11,16:00:00,172.4,173.47,172.2,173.4,2569917,0
                2017-09-11,17:00:00,173.39,173.89,172.88,172.95,1985972,0
                2017-09-11,18:00:00,172.93,173.29,172.66,173.12,1249627,0
                2017-09-11,19:00:00,173.14,173.465,173,173.2925,846283,0
                2017-09-11,20:00:00,173.3,173.62,173.19,173.475,796323,0
                2017-09-11,21:00:00,173.49,173.58,173.21,173.4029,700101,0
                2017-09-11,22:00:00,173.4,173.69,173.23,173.51,2247054,0
                2017-09-12,16:00:00,173.76,174,172.62,172.95,1600694,0
                2017-09-12,17:00:00,172.94,172.97,172.29,172.8485,1850525,0
                2017-09-12,18:00:00,172.83,173.06,172.5,172.5375,913774,0
                2017-09-12,19:00:00,172.54,172.82,172.33,172.55,811710,0
                2017-09-12,20:00:00,172.55,172.64,172.31,172.3779,756646,0
                2017-09-12,21:00:00,172.37,172.51,171.75,172.18,1296421,0
                2017-09-12,22:00:00,172.1899,172.95,171.96,172.95,1853689,0
                2017-09-13,16:00:00,173.01,173.06,172.06,172.79,1219091,0
                2017-09-13,17:00:00,172.8,172.99,172.36,172.66,1353380,0
                2017-09-13,18:00:00,172.68,172.79,172.1307,172.29,929711,0
                2017-09-13,19:00:00,172.28,172.88,172.27,172.85,600868,0
                2017-09-13,20:00:00,172.84,172.92,172.26,172.71,1141623,0
                2017-09-13,21:00:00,172.73,172.91,172.62,172.76,690702,0
                2017-09-13,22:00:00,172.77,173.17,172.64,173.05,1951351,0
                2017-09-14,16:00:00,172.26,172.28,170.5,171.48,3413922,0
                2017-09-14,17:00:00,171.47,172,171.31,171.86,2025746,0
                2017-09-14,18:00:00,171.86,171.95,171.38,171.44,1295512,0
                2017-09-14,19:00:00,171.4383,171.53,170.7701,171.36,1573507,0
                2017-09-14,20:00:00,171.38,171.585,170.98,171.07,880249,0
                2017-09-14,21:00:00,171.07,171.32,170.97,171.1276,1000415,0
                2017-09-14,22:00:00,171.135,171.2644,170.84,170.96,3505708,0
                2017-09-15,16:00:00,170.88,171.35,170.26,171.02,4626553,0
                2017-09-15,17:00:00,171.02,172.34,170.81,171.9,2152852,0
                2017-09-15,18:00:00,171.9014,172.01,171.4,171.59,922110,0
                2017-09-15,19:00:00,171.59,171.84,171.5,171.69,698595,0
                2017-09-15,20:00:00,171.69,171.79,171.45,171.6,489550,0
                2017-09-15,21:00:00,171.5912,171.75,171.3914,171.72,453983,0
                2017-09-15,22:00:00,171.73,171.78,171.32,171.58,3372272,0
                2017-09-18,16:00:00,171.99,172.07,171.27,171.82,1238452,0
                2017-09-18,17:00:00,171.86,171.9402,171.14,171.16,1435108,0
                2017-09-18,18:00:00,171.155,171.58,171.14,171.375,1034295,0
                2017-09-18,19:00:00,171.375,171.54,170.892,171.24,1068328,0
                2017-09-18,20:00:00,171.24,171.25,170.8,170.96,917132,0
                2017-09-18,21:00:00,170.9583,171.03,169.34,169.8168,2447027,0
                2017-09-18,22:00:00,169.8199,170.26,169.79,170.01,1899851,0
                2017-09-19,16:00:00,170.62,171.82,170.36,171.04,2666461,0
                2017-09-19,17:00:00,171.06,171.55,170.86,171.54,1519011,0
                2017-09-19,18:00:00,171.5411,172,171.12,171.74,1296463,0
                2017-09-19,19:00:00,171.735,172.24,171.7,171.783,995548,0
                2017-09-19,20:00:00,171.77,171.81,171.52,171.63,595006,0
                2017-09-19,21:00:00,171.63,172.17,171.63,171.8874,894959,0
                2017-09-19,22:00:00,171.88,172.56,171.77,172.52,3361600,0
                2017-09-20,16:00:00,172.5,173.05,171.91,172.436,1532373,0
                2017-09-20,17:00:00,172.49,172.5,170.91,170.94,1882462,0
                2017-09-20,18:00:00,170.99,171.91,170.7,171.42,1754497,0
                2017-09-20,19:00:00,171.43,172.0499,171.37,171.74,701282,0
                2017-09-20,20:00:00,171.75,172.34,171.68,172.2068,595816,0
                2017-09-20,21:00:00,172.2,172.3228,170.8901,171.67,1933222,0
                2017-09-20,22:00:00,171.67,172.37,171.38,172.17,2321029,0
                2017-09-21,16:00:00,171.69,171.78,170.11,170.4176,1923218,0
                2017-09-21,17:00:00,170.41,170.95,170.01,170.645,1802748,0
                2017-09-21,18:00:00,170.64,172.27,170.63,171.79,1898152,0
                2017-09-21,19:00:00,171.83,172.17,171.57,171.735,744466,0
                2017-09-21,20:00:00,171.76,172.19,171.71,171.9,603496,0
                2017-09-21,21:00:00,171.9,172.09,171.53,171.93,732452,0
                2017-09-21,22:00:00,171.93,172.02,171.1,171.11,1549501,0
                2017-09-22,16:00:00,170.21,171.7,170.2,171.04,1528102,0
                2017-09-22,17:00:00,171.09,171.73,170.61,170.66,1213718,0
                2017-09-22,18:00:00,170.67,170.9,170.3,170.4544,1129049,0
                2017-09-22,19:00:00,170.455,170.4999,169.69,169.72,1486495,0
                2017-09-22,20:00:00,169.7246,170.18,169.22,169.955,1306114,0
                2017-09-22,21:00:00,169.97,170.6157,169.81,170.2223,1009723,0
                2017-09-22,22:00:00,170.24,170.66,169.97,170.54,2891812,0
                2017-09-25,16:00:00,169.24,169.3,164.25,164.5,7673085,0
                2017-09-25,17:00:00,164.5,165.7,164.11,164.56,8126863,0
                2017-09-25,18:00:00,164.55,164.99,163.89,164.3,3986187,0
                2017-09-25,19:00:00,164.306,164.3618,162.78,163.9401,3761738,0
                2017-09-25,20:00:00,163.945,164.1,162.8,163.1555,2185387,0
                2017-09-25,21:00:00,163.155,163.28,161.56,162.72,4213188,0
                2017-09-25,22:00:00,162.72,163.19,162.32,162.87,6664367,0
                2017-09-26,16:00:00,164.5,164.88,163.53,163.9538,3979814,0
                2017-09-26,17:00:00,163.95,165.39,163.33,163.485,4087164,0
                2017-09-26,18:00:00,163.47,163.6,162.78,163.01,2683532,0
                2017-09-26,19:00:00,163.01,164.35,163,164.1278,2086545,0
                2017-09-26,20:00:00,164.13,165.5,164.103,165.03,2472074,0
                2017-09-26,21:00:00,165.02,165.24,164.3,164.4132,1656648,0
                2017-09-26,22:00:00,164.415,164.99,164.1,164.21,2410436,0
                2017-09-27,16:00:00,165.9,167.14,165.57,166.74,3913309,0
                2017-09-27,17:00:00,166.73,166.95,165.86,166.67,2198970,0
                2017-09-27,18:00:00,166.64,166.74,166.2,166.41,1063139,0
                2017-09-27,19:00:00,166.43,166.82,166.14,166.82,903477,0
                2017-09-27,20:00:00,166.83,167.29,166.7794,167.25,1332143,0
                2017-09-27,21:00:00,167.25,168.18,167.24,167.77,2455149,0
                2017-09-27,22:00:00,167.78,168.34,167.63,167.68,3912593,0
                2017-09-28,16:00:00,167.94,168.399,167.16,168.11,2261661,0
                2017-09-28,17:00:00,168.09,169.0696,168.06,168.6196,2146271,0
                2017-09-28,18:00:00,168.6173,168.87,167.99,168.16,1329327,0
                2017-09-28,19:00:00,168.17,168.31,167.79,168.1,969834,0
                2017-09-28,20:00:00,168.1167,168.69,167.26,168.58,1138931,0
                2017-09-28,21:00:00,168.58,168.665,168.12,168.44,714588,0
                2017-09-28,22:00:00,168.45,168.82,168,168.73,1884493,0
                2017-09-29,16:00:00,168.83,169.89,168.81,169.5,2110580,0
                2017-09-29,17:00:00,169.56,170.88,169.38,170.68,2446081,0
                2017-09-29,18:00:00,170.6764,170.96,170.34,170.58,1512859,0
                2017-09-29,19:00:00,170.585,171.39,170.5,171.35,1490295,0
                2017-09-29,20:00:00,171.3468,171.66,171.11,171.2,1162494,0
                2017-09-29,21:00:00,171.2042,171.29,170.48,170.64,968716,0
                2017-09-29,22:00:00,170.64,170.97,170.28,170.81,2244755,0
                2017-10-02,16:00:00,171.39,171.87,170.37,170.8,2421692,0
                2017-10-02,17:00:00,170.77,171.0629,170.25,170.73,1573368,0
                2017-10-02,18:00:00,170.73,170.915,169.1,169.1827,1717024,0
                2017-10-02,19:00:00,169.18,169.7,168.75,169.59,1393249,0
                2017-10-02,20:00:00,169.59,169.8856,169.47,169.65,778156,0
                2017-10-02,21:00:00,169.65,170.33,169.53,169.83,1144629,0
                2017-10-02,22:00:00,169.82,169.98,169.25,169.47,2400863,0
                2017-10-03,16:00:00,169.3,170.73,169.2,170.59,1585661,0
                2017-10-03,17:00:00,170.59,170.7,169.44,170.3365,1546335,0
                2017-10-03,18:00:00,170.32,170.578,169.97,170.0568,651114,0
                2017-10-03,19:00:00,170.06,170.265,169.82,169.98,675029,0
                2017-10-03,20:00:00,169.9769,170.1,169.83,169.989,517457,0
                2017-10-03,21:00:00,169.97,170.255,169.96,170.08,452166,0
                2017-10-03,22:00:00,170.087,170.17,169.76,169.96,1579778,0
                2017-10-04,16:00:00,169.83,170.24,169.12,169.786,1401682,0
                2017-10-04,17:00:00,169.785,170.65,169.6001,170.359,1426202,0
                2017-10-04,18:00:00,170.36,170.67,170.0277,170.09,1010196,0
                2017-10-04,19:00:00,170.0844,170.54,169.9,169.95,740658,0
                2017-10-04,20:00:00,169.95,170.0011,168.89,169.31,1764720,0
                2017-10-04,21:00:00,169.31,169.49,169.05,169.22,1023139,0
                2017-10-04,22:00:00,169.219,169.43,168.29,168.42,2940100,0
                2017-10-05,16:00:00,169.18,169.75,168.76,168.82,1952432,0
                2017-10-05,17:00:00,168.79,169.63,168.6,168.66,2317129,0
                2017-10-05,18:00:00,168.67,169.25,168.65,168.935,1050783,0
                2017-10-05,19:00:00,168.92,170.75,168.9199,170.6,2133708,0
                2017-10-05,20:00:00,170.59,170.89,170.38,170.64,1117746,0
                2017-10-05,21:00:00,170.63,170.9,170.45,170.76,769947,0
                2017-10-05,22:00:00,170.76,171.31,170.75,171.24,3030774,0
                2017-10-06,16:00:00,170.25,170.99,169.75,170.495,1940841,0
                2017-10-06,17:00:00,170.49,170.88,170.11,170.2599,1618602,0
                2017-10-06,18:00:00,170.26,171.351,170.26,171.3,1120217,0
                2017-10-06,19:00:00,171.319,172.28,171.13,172.05,1776810,0
                2017-10-06,20:00:00,172.0498,172.2,171.4391,171.69,1147914,0
                2017-10-06,21:00:00,171.68,171.71,171.36,171.6728,569716,0
                2017-10-06,22:00:00,171.67,172.37,171.55,172.23,2317180,0
                """;

        var dtf = DateTimeFormatter.ofPattern("yyyy-MM-dd H:m:s");
        var zone = ZoneId.of("America/Los_Angeles");
        series1Hours = new MockBarSeriesBuilder().withName("FB_1_hours").build();
        rawData1Hours.lines().forEach(aDataLine -> {
            var barData = aDataLine.split(",");
            var local = LocalDateTime.parse(barData[0] + " " + barData[1], dtf);
            var date = local.atZone(zone).toInstant();
            double open = Double.parseDouble(barData[2]);
            double high = Double.parseDouble(barData[3]);
            double low = Double.parseDouble(barData[4]);
            double close = Double.parseDouble(barData[5]);
            double volume = Double.parseDouble(barData[6]);
            series1Hours.barBuilder()
                    .endTime(date)
                    .openPrice(open)
                    .closePrice(close)
                    .highPrice(high)
                    .lowPrice(low)
                    .volume(volume)
                    .add();
        });
    }

    @Before
    public void initDataForMonthlyBarCount() {
        var rawData1Days = """
                2017/08/18,167.4100,15065590.0000,166.8400,168.6700,166.2100
                2017/08/17,166.9100,17009420.0000,169.3400,169.8600,166.8500
                2017/08/16,170.0000,15732840.0000,171.2500,171.3800,169.2400
                2017/08/15,171.0000,8713651.0000,171.4900,171.5000,170.0100
                2017/08/14,170.7500,12940140.0000,170.0900,171.0800,169.2900
                2017/08/11,168.0800,13778190.0000,167.9500,168.8200,166.8500
                2017/08/10,167.4000,20551720.0000,170.0600,170.5900,166.8500
                2017/08/09,171.1800,10800730.0000,169.9800,171.4500,169.5600
                2017/08/08,171.2300,14317200.0000,171.8800,173.0500,170.6200
                2017/08/07,171.9800,12765230.0000,169.9500,172.0600,169.6600
                2017/08/04,169.6200,10505980.0000,168.9700,170.0600,168.6900
                2017/08/03,168.5900,10519470.0000,169.3000,169.7000,168.2500
                2017/08/02,169.3000,17181110.0000,170.3000,170.5500,166.9100
                2017/08/01,169.8600,14286110.0000,169.8200,170.4700,169.0500
                2017/07/31,169.2500,25429310.0000,172.0000,172.7200,168.5500
                2017/07/28,172.4500,24546680.0000,169.0700,173.4300,169.0500
                2017/07/27,170.4400,68454830.0000,174.7000,175.4900,167.5000
                2017/07/26,165.6100,32989200.0000,166.0100,166.0100,164.1000
                2017/07/25,165.2800,15309000.0000,165.0100,165.5400,163.8619
                2017/07/24,166.0000,17208500.0000,164.6400,166.1700,164.3100
                2017/07/21,164.4300,14712450.0000,164.1600,165.0500,163.7500
                2017/07/20,164.5300,18409730.0000,164.8000,165.0000,162.8100
                2017/07/19,164.1400,26144510.0000,163.5900,165.7000,163.1700
                2017/07/18,162.8600,23686800.0000,159.6600,163.7300,159.4200
                2017/07/17,159.7300,12757430.0000,160.2500,160.7800,158.8100
                2017/07/14,159.9700,16305570.0000,160.1300,160.3200,159.3254
                2017/07/13,159.2600,13912150.0000,158.7400,159.7800,158.4227
                2017/07/12,158.9000,22710090.0000,156.4900,159.1600,156.2000
                2017/07/11,155.2700,13652540.0000,153.3700,155.4225,152.9100
                2017/07/10,153.5000,13326410.0000,151.6900,153.9800,151.5100
                2017/07/07,151.4400,13249750.0000,149.2500,151.9900,149.1900
                2017/07/06,148.8200,14934450.0000,149.0300,150.0400,148.0000
                2017/07/05,150.3400,14321330.0000,149.0000,150.8500,148.1300
                2017/07/03,148.4300,13862740.0000,151.7200,152.1500,147.8000
                2017/06/30,150.9800,14909670.0000,151.9000,151.9200,150.0600
                2017/06/29,151.0400,23948630.0000,152.2800,152.5000,148.9175
                2017/06/28,153.2400,16696230.0000,150.9200,153.4700,149.8600
                2017/06/27,150.5800,19351560.0000,152.8400,153.3100,150.3900
                2017/06/26,153.5900,18030200.0000,156.2500,156.5000,153.1954
                2017/06/23,155.0700,17897280.0000,152.7200,155.2000,152.6500
                2017/06/22,153.4000,12835380.0000,153.0100,154.5500,152.9100
                2017/06/21,153.9100,14943770.0000,152.3600,154.0800,151.8800
                2017/06/20,152.2500,14733590.0000,152.8800,153.8400,152.2100
                2017/06/19,152.8700,18944190.0000,151.7100,153.5700,151.7100
                2017/06/16,150.6400,22843010.0000,149.5900,150.8300,148.6000
                2017/06/15,149.8000,18956910.0000,147.6700,150.0366,146.3747
                2017/06/14,150.2500,20774910.0000,151.2600,152.4000,149.0500
                2017/06/13,150.6800,20474720.0000,150.1500,151.1800,148.9000
                2017/06/12,148.4400,33150610.0000,148.1700,149.1950,144.5600
                2017/06/09,149.6000,35541670.0000,154.7700,155.5900,146.6100
                2017/06/08,154.7100,17795860.0000,154.0800,154.7300,153.1000
                2017/06/07,153.1200,12040430.0000,153.2700,153.7500,152.3400
                2017/06/06,152.8100,13443610.0000,153.4100,154.5200,152.4800
                2017/06/05,153.6300,12504820.0000,153.6400,154.7088,153.4100
                2017/06/02,153.6100,16838650.0000,151.8500,153.6300,151.3000
                2017/06/01,151.5300,14511530.0000,151.7500,152.2900,150.3000
                2017/05/31,151.4600,18001140.0000,152.7000,153.3500,151.0900
                2017/05/30,152.3800,13213700.0000,151.9700,152.9000,151.6400
                2017/05/26,152.1300,14984540.0000,152.2300,152.2500,151.1500
                2017/05/25,151.9600,19827210.0000,150.3000,152.5900,149.9500
                2017/05/24,150.0400,17914740.0000,148.5100,150.2300,148.4200
                2017/05/23,148.0700,12807840.0000,148.5200,148.8100,147.2500
                2017/05/22,148.2400,12578390.0000,148.0800,148.5900,147.6900
                2017/05/19,148.0600,16165160.0000,148.4450,149.3900,147.9600
                2017/05/18,147.6600,22778870.0000,144.7200,148.1500,144.5100
                2017/05/17,144.8500,28232610.0000,148.0000,148.6700,144.4216
                2017/05/16,149.7800,14506870.0000,150.1100,150.2100,149.0300
                2017/05/15,150.1900,14952950.0000,150.1700,151.4800,149.7700
                2017/05/12,150.3300,9584769.0000,150.4000,150.4600,149.6300
                2017/05/11,150.0400,11832750.0000,150.3100,150.6500,149.4100
                2017/05/10,150.2900,11994140.0000,150.2300,150.5200,148.8600
                2017/05/09,150.4800,17381800.0000,151.4900,152.5900,150.2100
                2017/05/08,151.0600,15813350.0000,150.7100,151.0800,149.7400
                2017/05/05,150.2400,17104730.0000,151.4500,151.6300,149.7900
                2017/05/04,150.8500,36185180.0000,150.1700,151.5200,148.7200
                2017/05/03,151.8000,28301550.0000,153.6000,153.6000,151.3400
                2017/05/02,152.7800,21617190.0000,153.3400,153.4400,151.6600
                2017/05/01,152.4600,25170200.0000,151.7400,152.5700,151.4200
                2017/04/28,150.2500,30607510.0000,149.5000,151.5300,149.0700
                2017/04/27,147.7000,11072600.0000,146.6700,147.7500,146.1400
                2017/04/26,146.5600,12388100.0000,147.0900,147.5900,146.0900
                2017/04/25,146.4900,17718030.0000,145.7900,147.1500,145.7898
                2017/04/24,145.4700,14397480.0000,144.9600,145.6738,144.3400
                2017/04/21,143.6800,12172640.0000,143.9000,144.1700,142.2700
                2017/04/20,143.8000,15948700.0000,142.9500,144.2500,142.6890
                2017/04/19,142.2700,15544500.0000,141.3500,143.0400,141.2700
                2017/04/18,140.9600,14795020.0000,141.2700,141.9050,140.6100
                2017/04/17,141.4200,11488510.0000,139.7600,141.5500,139.7500
                2017/04/13,139.3900,10939950.0000,139.6200,140.5800,139.3300
                2017/04/12,139.5800,11600930.0000,139.7200,140.4000,139.4400
                2017/04/11,139.9200,16627940.0000,140.8000,141.0299,138.8100
                2017/04/10,141.0400,9033921.0000,141.0000,141.4300,140.6300
                2017/04/07,140.7800,11811450.0000,141.2000,141.5500,140.2400
                2017/04/06,141.1700,15089610.0000,142.1100,142.2200,140.9100
                2017/04/05,141.8500,17132150.0000,142.2600,143.4400,141.2900
                2017/04/04,141.7300,11934110.0000,141.8600,142.0900,141.2700
                2017/04/03,142.2800,13552550.0000,141.9300,142.4700,140.8200
                2017/03/31,142.0500,11366390.0000,142.3100,142.6300,141.8900
                2017/03/30,142.4100,12393610.0000,142.4000,142.9500,141.8500
                2017/03/29,142.6500,16504590.0000,141.9900,142.8600,141.4300
                2017/03/28,141.7600,14660670.0000,140.3600,141.9500,140.0100
                2017/03/27,140.3200,12791820.0000,139.0500,140.6500,138.7700
                2017/03/24,140.3400,16636900.0000,140.0800,141.0244,139.7600
                2017/03/23,139.5300,12992700.0000,139.4800,140.3900,139.0900
                2017/03/22,139.5900,17020610.0000,137.9300,139.7900,137.6000
                2017/03/21,138.5100,29855980.0000,141.1500,142.3082,138.4000
                2017/03/20,139.9400,12002150.0000,139.7100,140.1900,139.2500
                2017/03/17,139.8400,20487730.0000,140.3400,140.3400,139.7000
                2017/03/16,139.9900,13604260.0000,140.2000,140.2500,139.7300
                2017/03/15,139.7200,19315340.0000,139.2900,140.1000,138.4900
                2017/03/14,139.3200,12935370.0000,139.4600,139.4600,138.5200
                2017/03/13,139.6000,10949000.0000,138.7100,139.6800,138.6729
                2017/03/10,138.7900,16299220.0000,138.9100,139.4900,138.2200
                2017/03/09,138.2400,15523900.0000,137.7200,138.5700,137.4000
                2017/03/08,137.7200,10174840.0000,137.1500,137.9900,137.0516
                2017/03/07,137.3000,13517880.0000,137.0300,138.3700,136.9900
                2017/03/06,137.4200,12562040.0000,136.8800,137.8300,136.5100
                2017/03/03,137.1700,11154380.0000,136.6300,137.3300,136.0800
                2017/03/02,136.7600,12278560.0000,137.0900,137.8200,136.3100
                2017/03/01,137.4200,16241330.0000,136.4700,137.4800,136.3000
                2017/02/28,135.5400,16096310.0000,136.7900,136.8050,134.7500
                2017/02/27,136.4100,14300970.0000,135.2600,137.1846,135.0200
                2017/02/24,135.4400,12617180.0000,134.1600,135.6200,134.1600
                2017/02/23,135.3600,18408460.0000,135.8900,136.1200,134.3300
                2017/02/22,136.1200,27331930.0000,133.6000,136.7900,133.4600
                2017/02/21,133.7200,14735860.0000,133.5000,133.9100,132.9000
                2017/02/17,133.5300,12265480.0000,133.5000,134.0912,133.1700
                2017/02/16,133.8400,12816260.0000,133.0700,133.8700,133.0220
                2017/02/15,133.4400,13215470.0000,133.4500,133.7000,132.6600
                2017/02/14,133.8500,14346090.0000,134.1000,134.2300,132.5500
                2017/02/13,134.0500,13511640.0000,134.6975,134.6975,133.7000
                2017/02/10,134.1900,15050270.0000,134.1000,134.9400,133.6800
                2017/02/09,134.1400,16454060.0000,134.4900,134.5000,133.3100
                2017/02/08,134.2000,22370760.0000,132.6000,134.4400,132.4400
                2017/02/07,131.8400,14585030.0000,132.2400,133.0000,131.6610
                2017/02/06,132.0600,17015610.0000,130.9800,132.0600,130.3000
                2017/02/03,130.9800,24776070.0000,131.2400,132.8500,130.7600
                2017/02/02,130.8400,54281800.0000,133.2200,135.4900,130.4000
                2017/02/01,133.2300,47329480.0000,132.2500,133.4900,130.6800
                2017/01/31,130.3200,19642550.0000,130.1700,130.6600,129.5157
                2017/01/30,130.9800,18919750.0000,131.5800,131.5800,129.6000
                2017/01/27,132.1800,19505970.0000,132.6800,132.9500,131.0800
                2017/01/26,132.7800,19964800.0000,131.6300,133.1400,131.4401
                2017/01/25,131.4800,18745640.0000,130.0000,131.7400,129.7700
                2017/01/24,129.3700,15140910.0000,129.3800,129.9000,128.3800
                2017/01/23,128.9300,16566300.0000,127.3100,129.2500,126.9500
                2017/01/20,127.0400,19068380.0000,128.1000,128.4800,126.7800
                2017/01/19,127.5500,12171270.0000,128.2300,128.3500,127.4500
                2017/01/18,127.9200,13107440.0000,128.4100,128.4300,126.8400
                2017/01/17,127.8700,15279990.0000,128.0400,128.3400,127.4000
                2017/01/13,128.3400,24857410.0000,127.4900,129.2700,127.3700
                2017/01/12,126.6200,18596580.0000,125.6100,126.7300,124.8000
                2017/01/11,126.0900,18334560.0000,124.3500,126.1200,124.0600
                2017/01/10,124.3500,17299590.0000,124.8200,125.5000,124.2800
                2017/01/09,124.9000,22874170.0000,123.5500,125.4300,123.0400
                2017/01/06,123.4100,28525570.0000,120.9800,123.8800,120.0300
                2017/01/05,120.6700,19459380.0000,118.8600,120.9500,118.3209
                2017/01/04,118.6900,19594560.0000,117.5500,119.6600,117.2900
                2017/01/03,116.8600,20635600.0000,116.0300,117.8400,115.5100
                """;

        var dtf = DateTimeFormatter.ofPattern("yyyy/MM/dd");
        var dataLine = rawData1Days.split("\\n");
        series1Days = new MockBarSeriesBuilder().withName("FB_daily").build();
        for (var i = dataLine.length - 1; i >= 0; i--) {
            var barData = dataLine[i].strip().split(",");
            var date = LocalDate.parse(barData[0], dtf).atStartOfDay(ZoneOffset.UTC).toInstant();
            var close = Double.parseDouble(barData[1]);
            var volume = Double.parseDouble(barData[2]);
            var open = Double.parseDouble(barData[3]);
            var high = Double.parseDouble(barData[4]);
            var low = Double.parseDouble(barData[5]);
            series1Days.barBuilder()
                    .endTime(date)
                    .openPrice(open)
                    .highPrice(high)
                    .lowPrice(low)
                    .closePrice(close)
                    .volume(volume)
                    .add();
        }
    }

    @Before
    public void initDataForYearlyBarCount() {
        var rawData1Week = """
                2012-05-14,42.049999,45.000000,38.000000,38.230000,38.230000,573576400
                2012-05-21,36.529999,36.660000,30.940001,31.910000,31.910000,430966300
                2012-05-28,31.480000,31.690001,26.830000,27.719999,27.719999,288826000
                2012-06-04,27.200001,27.760000,25.520000,27.100000,27.100000,203386400
                2012-06-11,27.180000,30.100000,26.840000,30.010000,30.010000,121558000
                2012-06-18,29.959999,33.450001,29.410000,33.049999,33.049999,186090800
                2012-06-25,32.860001,33.439999,30.760000,31.100000,31.100000,115019800
                2012-07-02,31.250000,31.900000,30.549999,31.730000,31.730000,43863300
                2012-07-09,32.099998,32.880001,30.549999,30.719999,30.719999,64494000
                2012-07-16,30.500000,30.500000,27.150000,28.760000,28.760000,97506700
                2012-07-23,28.120001,29.490000,22.280001,23.709999,23.709999,228860400
                2012-07-30,24.000000,24.040001,19.820000,21.090000,21.090000,267091200
                2012-08-06,21.389999,22.450001,20.219999,21.809999,21.809999,135504600
                2012-08-13,22.150000,22.450001,19.000000,19.049999,19.049999,399001700
                2012-08-20,19.049999,20.129999,18.750000,19.410000,19.410000,284155300
                2012-08-27,19.490000,19.530001,18.030001,18.059999,18.059999,151657400
                2012-09-03,18.080000,19.420000,17.549999,18.980000,18.980000,189842400
                2012-09-10,19.059999,22.080000,18.549999,22.000000,22.000000,334751400
                2012-09-17,22.670000,23.370001,21.370001,22.860001,22.860001,274677900
                2012-09-24,21.780001,21.980000,19.799999,21.660000,21.660000,259372000
                2012-10-01,22.080000,22.590000,20.879999,20.910000,20.910000,200025600
                2012-10-08,20.400000,20.750000,19.450001,19.520000,19.520000,139347000
                2012-10-15,19.680000,20.480000,18.799999,19.000000,19.000000,173091300
                2012-10-22,19.200001,24.250000,19.049999,21.940001,21.940001,489096200
                2012-10-29,20.820000,21.690001,20.730000,21.180000,21.180000,175436500
                2012-11-05,21.100000,21.480000,19.129999,19.209999,19.209999,170816300
                2012-11-12,19.150000,23.930000,18.870001,23.559999,23.559999,554915200
                2012-11-19,23.959999,24.680000,22.700001,24.000000,24.000000,251059900
                2012-11-26,24.940001,28.000000,24.809999,28.000000,28.000000,474640500
                2012-12-03,28.000000,28.879999,26.680000,27.490000,27.490000,353125000
                2012-12-10,27.170000,28.750000,26.760000,26.809999,26.809999,347095000
                2012-12-17,26.770000,28.219999,26.120001,26.260000,26.260000,269775700
                2012-12-24,26.500000,27.180000,25.150000,25.910000,25.910000,161462000
                2012-12-31,26.200001,28.930000,26.110001,28.760000,28.760000,266076900
                2013-01-07,28.690001,31.959999,28.650000,31.719999,31.719999,419355200
                2013-01-14,32.080002,32.209999,29.270000,29.660000,29.660000,437356300
                2013-01-21,29.750000,31.930000,29.740000,31.540001,31.540001,202351800
                2013-01-28,31.879999,32.509998,28.740000,29.730000,29.730000,496942700
                2013-02-04,29.059999,29.290001,28.010000,28.549999,28.549999,250935200
                2013-02-11,28.610001,28.750000,27.100000,28.320000,28.320000,249749600
                2013-02-18,28.230000,29.080000,26.820000,27.129999,27.129999,177487100
                2013-02-25,27.160000,28.120001,26.340000,27.780001,27.780001,247676000
                2013-03-04,27.760000,28.680000,27.209999,27.959999,27.959999,225294600
                2013-03-11,28.010000,28.639999,26.559999,26.650000,26.650000,162075000
                2013-03-18,26.370001,26.900000,25.559999,25.730000,25.730000,138706800
                2013-03-25,25.750000,26.280001,24.719999,25.580000,25.580000,147039300
                2013-04-01,25.629999,27.799999,25.280001,27.389999,27.389999,252181200
                2013-04-08,27.190001,28.100000,26.420000,27.400000,27.400000,156582400
                2013-04-15,27.160000,27.480000,25.150000,25.730000,25.730000,143521800
                2013-04-22,25.809999,27.620001,25.700001,26.850000,26.850000,120777000
                2013-04-29,27.160000,29.070000,26.860001,28.309999,28.309999,292777800
                2013-05-06,28.330000,28.459999,26.570000,26.680000,26.680000,184157700
                2013-05-13,26.600000,27.330000,25.900000,26.250000,26.250000,149260700
                2013-05-20,26.180000,26.190001,24.080000,24.309999,24.309999,210369700
                2013-05-27,24.540001,24.950001,23.260000,24.350000,24.350000,210975700
                2013-06-03,24.270000,24.320000,22.670000,23.290001,23.290001,194274200
                2013-06-10,24.059999,24.600000,23.260000,23.629999,23.629999,176591100
                2013-06-17,23.910000,25.190001,23.650000,24.530001,24.530001,190763700
                2013-06-24,23.950001,24.980000,23.379999,24.879999,24.879999,226702500
                2013-07-01,24.969999,25.059999,24.150000,24.370001,24.370001,69610200
                2013-07-08,24.469999,26.000000,24.420000,25.910000,25.910000,127489600
                2013-07-15,25.930000,26.780001,25.600000,25.879999,25.879999,147916700
                2013-07-22,25.990000,34.880001,25.719999,34.009998,34.009998,639870300
                2013-07-29,34.070000,38.490002,34.009998,38.049999,38.049999,632255300
                2013-08-05,38.430000,39.320000,37.700001,38.500000,38.500000,297633700
                2013-08-12,38.200001,38.500000,36.020000,37.080002,37.080002,247326000
                2013-08-19,37.430000,40.630001,37.139999,40.549999,40.549999,270095200
                2013-08-26,40.900002,42.259998,39.419998,41.290001,41.290001,350814200
                2013-09-02,41.840000,44.610001,41.439999,43.950001,43.950001,258927900
                2013-09-09,44.360001,45.619999,43.110001,44.310001,44.310001,323500900
                2013-09-16,44.849998,47.599998,42.430000,47.490002,47.490002,421156600
                2013-09-23,47.279999,51.279999,46.290001,51.240002,51.240002,479403400
                2013-09-30,50.139999,51.599998,49.060001,51.040001,51.040001,417535000
                2013-10-07,50.730000,51.290001,45.259998,49.110001,49.110001,498784000
                2013-10-14,48.310001,54.830002,47.910000,54.220001,54.220001,374408000
                2013-10-21,54.680000,54.810001,51.130001,51.950001,51.950001,290506000
                2013-10-28,51.540001,52.090000,46.500000,49.750000,49.750000,646530000
                2013-11-04,49.369999,50.450001,47.250000,47.529999,47.529999,392954000
                2013-11-11,47.040001,49.570000,45.730000,49.009998,49.009998,345921000
                2013-11-18,48.470001,48.840000,45.720001,46.230000,46.230000,290876000
                2013-11-25,46.360001,47.209999,43.549999,47.009998,47.009998,232527900
                2013-12-02,46.900002,49.389999,46.259998,47.939999,47.939999,230543000
                2013-12-09,48.090000,53.500000,47.740002,53.320000,53.320000,345675000
                2013-12-16,53.250000,55.889999,52.910000,55.119999,55.119999,569450200
                2013-12-23,55.500000,58.580002,55.250000,55.439999,55.439999,260481800
                2013-12-30,54.930000,55.650002,53.430000,54.560001,54.560001,192824900
                2014-01-06,54.419998,58.959999,54.049999,57.939999,57.939999,337445200
                2014-01-13,57.910000,58.570000,55.380001,56.299999,56.299999,209568900
                2014-01-20,56.599998,59.310001,54.400002,54.450001,54.450001,213174600
                2014-01-27,54.730000,63.369999,51.849998,62.570000,62.570000,453084400
                2014-02-03,63.029999,64.570000,60.700001,64.320000,64.320000,275328000
                2014-02-10,64.300003,67.580002,63.349998,67.089996,67.089996,235230400
                2014-02-17,66.940002,70.110001,65.730003,68.589996,68.589996,307758300
                2014-02-24,68.739998,71.440002,67.379997,68.459999,68.459999,292457400
                2014-03-03,66.959999,71.970001,66.510002,69.800003,69.800003,258358800
                2014-03-10,70.769997,72.589996,67.459999,67.720001,67.720001,270938400
                2014-03-17,68.180000,69.599998,66.180000,67.239998,67.239998,241443900
                2014-03-24,67.190002,67.360001,57.980000,60.009998,60.009998,431687900
                2014-03-31,60.779999,63.910000,56.320000,56.750000,56.750000,387652400
                2014-04-07,55.900002,63.180000,55.439999,58.529999,58.529999,493979000
                2014-04-14,60.090000,60.580002,55.880001,58.939999,58.939999,347762000
                2014-04-21,59.459999,63.650002,57.570000,57.709999,57.709999,448174700
                2014-04-28,58.049999,62.279999,54.660000,60.459999,60.459999,396026000
                2014-05-05,59.669998,61.349998,56.259998,57.240002,57.240002,294380000
                2014-05-12,57.980000,60.889999,57.310001,58.020000,58.020000,249276000
                2014-05-19,57.889999,61.480000,57.570000,61.349998,61.349998,248451000
                2014-05-26,61.619999,64.300003,61.570000,63.299999,63.299999,191430500
                2014-06-02,63.230000,64.360001,62.049999,62.500000,62.500000,194521000
                2014-06-09,62.400002,66.470001,61.790001,64.500000,64.500000,236346000
                2014-06-16,64.160004,65.750000,63.349998,64.500000,64.500000,175042000
                2014-06-23,64.320000,68.000000,64.220001,67.599998,67.599998,230378000
                2014-06-30,67.459999,68.440002,65.760002,66.290001,66.290001,127444000
                2014-07-07,66.300003,66.589996,62.209999,66.339996,66.339996,232737000
                2014-07-14,67.129997,68.459999,66.040001,68.419998,68.419998,192935800
                2014-07-21,68.809998,76.739998,68.500000,75.190002,75.190002,338457000
                2014-07-28,75.169998,75.500000,71.550003,72.360001,72.360001,207429000
                2014-08-04,72.360001,74.000000,71.790001,73.059998,73.059998,162092000
                2014-08-11,73.459999,74.650002,72.220001,73.629997,73.629997,142329600
                2014-08-18,74.000000,75.580002,73.570000,74.570000,74.570000,114569000
                2014-08-25,74.940002,75.989998,73.730003,74.820000,74.820000,128238000
                2014-09-01,75.010002,77.480003,74.820000,77.260002,77.260002,123520000
                2014-09-08,77.260002,78.360001,76.199997,77.480003,77.480003,145869800
                2014-09-15,77.150002,78.300003,73.070000,77.910004,77.910004,215816000
                2014-09-22,77.000000,78.940002,75.949997,78.790001,78.790001,165860000
                2014-09-29,78.120003,79.709999,75.639999,77.440002,77.440002,184848000
                2014-10-06,77.190002,77.949997,72.760002,72.910004,72.910004,168655000
                2014-10-13,73.230003,76.000000,70.320000,75.949997,75.949997,285636000
                2014-10-20,75.599998,80.820000,75.379997,80.669998,80.669998,176119000
                2014-10-27,80.739998,81.160004,72.900002,74.989998,74.989998,338315000
                2014-11-03,75.470001,76.800003,73.650002,75.599998,75.599998,158123000
                2014-11-10,75.360001,75.480003,73.540001,74.879997,74.879997,112752800
                2014-11-17,74.879997,75.660004,72.510002,73.750000,73.750000,117048200
                2014-11-24,73.540001,78.269997,73.349998,77.699997,77.699997,103041300
                2014-12-01,77.260002,77.309998,74.400002,76.360001,76.360001,103922900
                2014-12-08,76.180000,78.879997,74.779999,77.830002,77.830002,144856700
                2014-12-15,78.459999,80.000000,74.589996,79.879997,79.879997,167712100
                2014-12-22,80.080002,82.169998,80.000000,80.779999,80.779999,69594500
                2014-12-29,80.489998,80.959999,77.699997,78.449997,78.449997,66723400
                2015-01-05,77.980003,79.250000,75.360001,77.739998,77.739998,120996500
                2015-01-12,77.839996,78.080002,73.540001,75.180000,75.180000,126213900
                2015-01-19,75.720001,78.190002,74.820000,77.830002,77.830002,83690100
                2015-01-26,77.980003,78.470001,74.209999,75.910004,75.910004,196620200
                2015-02-02,76.110001,76.349998,73.750000,74.470001,74.470001,125159500
                2015-02-09,74.050003,76.870003,73.449997,75.739998,75.739998,88739900
                2015-02-16,75.300003,80.339996,75.080002,79.900002,79.900002,130371900
                2015-02-23,79.959999,81.370003,78.099998,78.970001,78.970001,130449000
                2015-03-02,79.000000,81.989998,78.519997,80.010002,80.010002,120626300
                2015-03-09,79.680000,79.910004,77.260002,78.050003,78.050003,96623700
                2015-03-16,77.959999,84.599998,77.360001,83.800003,83.800003,164584900
                2015-03-23,83.919998,86.070000,82.139999,83.300003,83.300003,148126900
                2015-03-30,83.809998,84.339996,80.870003,81.559998,81.559998,85910200
                2015-04-06,80.800003,83.419998,80.800003,82.040001,82.040001,83953600
                2015-04-13,81.930000,83.940002,80.370003,80.779999,80.779999,106702600
                2015-04-20,81.540001,85.589996,81.239998,81.529999,81.529999,204786400
                2015-04-27,81.870003,82.930000,78.110001,78.989998,78.989998,128787000
                2015-05-04,79.330002,79.690002,77.050003,78.510002,78.510002,105359300
                2015-05-11,78.480003,81.849998,76.790001,80.419998,80.419998,138179600
                2015-05-18,80.330002,81.690002,79.459999,80.540001,80.540001,95060100
                2015-05-25,80.430000,81.070000,78.879997,79.190002,79.190002,58548100
                2015-06-01,79.300003,82.949997,78.660004,82.139999,82.139999,105794700
                2015-06-08,81.820000,82.900002,79.320000,81.529999,81.529999,84975000
                2015-06-15,80.550003,83.190002,80.070000,82.510002,82.510002,100984900
                2015-06-22,83.410004,89.400002,83.309998,88.010002,88.010002,186937800
                2015-06-29,86.610001,87.949997,85.570000,87.290001,87.290001,101359900
                2015-07-06,86.489998,88.220001,85.230003,87.949997,87.949997,128648400
                2015-07-13,88.660004,95.389999,88.419998,94.970001,94.970001,163296800
                2015-07-20,95.849998,99.239998,94.809998,96.949997,96.949997,185477000
                2015-07-27,96.580002,97.279999,91.800003,94.010002,94.010002,271190000
                2015-08-03,93.529999,98.739998,92.800003,94.300003,94.300003,144762700
                2015-08-10,95.680000,95.900002,91.190002,94.419998,94.419998,103377900
                2015-08-17,94.419998,96.099998,85.610001,86.059998,86.059998,171220500
                2015-08-24,77.029999,91.480003,72.000000,91.010002,91.010002,256503500
                2015-08-31,90.599998,91.050003,86.500000,88.260002,88.260002,149671500
                2015-09-07,89.690002,92.080002,88.830002,92.050003,92.050003,107073900
                2015-09-14,92.309998,95.510002,91.599998,94.400002,94.400002,144827900
                2015-09-21,94.620003,96.489998,91.919998,92.769997,92.769997,145447900
                2015-09-28,92.080002,92.290001,85.720001,92.070000,92.070000,186677400
                2015-10-05,92.940002,94.269997,90.470001,93.239998,93.239998,120898000
                2015-10-12,93.320000,97.589996,92.669998,97.540001,97.540001,110153700
                2015-10-19,97.180000,102.849998,96.470001,102.190002,102.190002,145550000
                2015-10-26,102.199997,105.120003,101.550003,101.970001,101.970001,127425200
                2015-11-02,101.720001,110.650002,101.180000,107.099998,107.099998,182169800
                2015-11-09,107.000000,109.870003,103.830002,103.949997,103.949997,127675400
                2015-11-16,103.320000,107.879997,100.470001,107.320000,107.320000,147603100
                2015-11-23,107.190002,107.470001,104.389999,105.449997,105.449997,64538400
                2015-11-30,105.839996,107.919998,103.349998,106.180000,106.180000,112055400
                2015-12-07,106.480003,106.910004,101.910004,102.120003,102.120003,103236200
                2015-12-14,102.290001,107.750000,101.459999,104.040001,104.040001,126762800
                2015-12-21,104.910004,106.110001,103.599998,105.019997,105.019997,56671200
                2015-12-28,105.019997,107.739998,104.529999,104.660004,104.660004,61717200
                2016-01-04,101.949997,103.769997,97.029999,97.330002,97.330002,166842000
                2016-01-11,97.910004,100.580002,92.449997,94.970001,94.970001,186470500
                2016-01-18,96.529999,98.070000,89.370003,97.940002,97.940002,151064000
                2016-01-25,98.720001,112.839996,94.230003,112.209999,112.209999,288033600
                2016-02-01,112.269997,117.589996,103.180000,104.070000,104.070000,278373800
                2016-02-08,100.410004,105.110001,96.820000,102.010002,102.010002,258836600
                2016-02-15,103.800003,106.000000,100.239998,104.570000,104.570000,151758600
                2016-02-22,105.489998,109.449997,102.739998,107.919998,107.919998,151923800
                2016-02-29,107.599998,110.550003,106.750000,108.389999,108.389999,131538900
                2016-03-07,108.070000,109.419998,104.400002,109.410004,109.410004,123025000
                2016-03-14,109.279999,112.690002,108.769997,111.449997,111.449997,120110800
                2016-03-21,111.660004,113.190002,111.029999,113.050003,113.050003,73850200
                2016-03-28,113.320000,116.989998,112.949997,116.059998,116.059998,130320800
                2016-04-04,114.070000,114.889999,109.900002,110.629997,110.629997,161185000
                2016-04-11,110.699997,112.650002,106.519997,109.639999,109.639999,203519300
                2016-04-18,109.739998,114.040001,109.010002,110.559998,110.559998,131664500
                2016-04-25,109.870003,120.790001,106.309998,117.580002,117.580002,220003200
                2016-05-02,117.830002,119.639999,116.570000,119.489998,119.489998,124045200
                2016-05-09,119.540001,121.080002,118.900002,119.809998,119.809998,106140000
                2016-05-16,119.379997,119.610001,115.879997,117.349998,117.349998,113707600
                2016-05-23,117.419998,119.849998,115.940002,119.379997,119.379997,92255900
                2016-05-30,119.459999,120.099998,117.820000,118.470001,118.470001,65902100
                2016-06-06,118.620003,119.430000,116.260002,116.620003,116.620003,76723300
                2016-06-13,115.000000,115.480003,112.559998,113.019997,113.019997,113036700
                2016-06-20,113.769997,115.209999,111.000000,112.080002,112.080002,111618000
                2016-06-27,111.570000,115.180000,108.230003,114.190002,114.190002,122085200
                2016-07-04,113.940002,117.500000,112.970001,117.239998,117.239998,73287800
                2016-07-11,117.709999,118.720001,116.580002,116.860001,116.860001,80362700
                2016-07-18,117.320000,122.199997,116.889999,121.000000,121.000000,98680300
                2016-07-25,121.389999,128.330002,117.779999,123.940002,123.940002,196787900
                2016-08-01,123.849998,125.839996,122.070000,125.150002,125.150002,108722600
                2016-08-08,125.250000,126.089996,124.180000,124.879997,124.879997,69341500
                2016-08-15,124.910004,124.919998,122.779999,123.559998,123.559998,71400800
                2016-08-22,123.330002,125.190002,123.089996,124.959999,124.959999,68175200
                2016-08-29,124.349998,126.860001,124.349998,126.510002,126.510002,73475400
                2016-09-05,126.669998,131.979996,126.470001,127.099998,127.099998,96923100
                2016-09-12,125.959999,129.179993,125.750000,129.070007,129.070007,94156500
                2016-09-19,129.910004,130.729996,127.300003,127.959999,127.959999,83936500
                2016-09-26,127.370003,129.470001,126.800003,128.270004,128.270004,75684700
                2016-10-03,128.380005,129.279999,127.550003,128.990005,128.990005,64338300
                2016-10-10,129.679993,130.699997,126.750000,127.879997,127.879997,74196900
                2016-10-17,128.199997,132.130005,127.320000,132.070007,132.070007,73817500
                2016-10-24,132.720001,133.500000,129.270004,131.289993,131.289993,85178600
                2016-10-31,132.009995,132.119995,119.250000,120.750000,120.750000,171699500
                2016-11-07,122.830002,124.610001,115.269997,119.019997,119.019997,174979500
                2016-11-14,119.129997,119.129997,113.550003,117.019997,117.019997,159751300
                2016-11-21,118.199997,122.980003,117.800003,120.379997,120.379997,85755600
                2016-11-28,120.120003,122.099998,114.000000,115.400002,115.400002,135528600
                2016-12-05,115.949997,119.940002,115.070000,119.680000,119.680000,101153900
                2016-12-12,119.220001,122.500000,117.610001,119.870003,119.870003,118800800
                2016-12-19,119.849998,120.360001,116.300003,117.269997,117.269997,67506000
                2016-12-26,116.959999,118.680000,114.769997,115.050003,115.050003,52744400
                2017-01-02,116.029999,123.879997,115.510002,123.410004,123.410004,88332300
                2017-01-09,123.550003,129.270004,123.040001,128.339996,128.339996,101988300
                2017-01-16,128.039993,128.479996,126.779999,127.040001,127.040001,59628200
                2017-01-23,127.309998,133.139999,126.949997,132.179993,132.179993,90001600
                2017-01-30,131.580002,135.490005,129.520004,130.979996,130.979996,168057700
                2017-02-06,130.979996,134.940002,130.300003,134.190002,134.190002,85549000
                2017-02-13,134.699997,134.699997,132.550003,133.529999,133.529999,66200400
                2017-02-20,133.500000,136.789993,132.899994,135.440002,135.440002,73120200
                2017-02-27,135.259995,137.820007,134.750000,137.169998,137.169998,70100900
                2017-03-06,136.880005,139.490005,136.509995,138.789993,138.789993,68309200
                2017-03-13,138.710007,140.339996,138.490005,139.839996,139.839996,77450000
                2017-03-20,139.710007,142.309998,137.600006,140.339996,140.339996,88737200
                2017-03-27,139.050003,142.949997,138.770004,142.050003,142.050003,67889800
                2017-04-03,141.929993,143.440002,140.240005,140.779999,140.779999,70592400
                2017-04-10,141.000000,141.429993,138.809998,139.389999,139.389999,48255600
                2017-04-17,139.759995,144.250000,139.750000,143.679993,143.679993,70241300
                2017-04-24,144.960007,151.529999,144.339996,150.250000,150.250000,86497000
                2017-05-01,151.740005,153.600006,148.720001,150.240005,150.240005,130245200
                2017-05-08,150.710007,152.589996,148.860001,150.330002,150.330002,66802200
                2017-05-15,150.169998,151.479996,144.419998,148.059998,148.059998,97135100
                2017-05-22,148.080002,152.589996,147.250000,152.130005,152.130005,78129100
                2017-05-29,151.970001,153.630005,150.300003,153.610001,153.610001,62634900
                2017-06-05,153.639999,155.589996,146.610001,149.600006,149.600006,91421300
                2017-06-12,148.169998,152.399994,144.559998,150.639999,150.639999,116339000
                2017-06-19,151.710007,155.199997,151.710007,155.070007,155.070007,79842700
                2017-06-26,156.250000,156.500000,148.919998,150.979996,150.979996,92968600
                2017-07-03,151.720001,152.149994,147.800003,151.440002,151.440002,56679800
                2017-07-10,151.690002,160.320007,151.509995,159.970001,159.970001,80086200
                2017-07-17,160.250000,165.699997,158.809998,164.429993,164.429993,96122400
                2017-07-24,164.639999,175.490005,163.860001,172.449997,172.449997,161455400
                2017-07-31,172.000000,172.720001,166.910004,169.619995,169.619995,78869200
                2017-08-07,169.949997,173.050003,166.850006,168.080002,168.080002,72620200
                2017-08-14,170.089996,171.500000,166.210007,167.410004,167.410004,69772900
                2017-08-21,167.160004,169.869995,165.820007,166.320007,166.320007,59799900
                2017-08-28,166.910004,172.919998,165.000000,172.020004,172.020004,59717100
                2017-09-04,171.270004,173.490005,169.550003,170.949997,170.949997,56165200
                2017-09-11,172.399994,174.000000,170.259995,171.639999,171.639999,63953800
                2017-09-18,171.990005,173.050003,169.220001,170.539993,170.539993,61645200
                2017-09-25,169.240005,171.660004,161.559998,170.869995,170.869995,111376500
                2017-10-02,171.389999,172.369995,168.289993,172.229996,172.229996,60993900
                """;

        var dtf = DateTimeFormatter.ofPattern("yyyy-MM-dd");
        series1Weeks = new MockBarSeriesBuilder().withName("FB_daily").build();
        rawData1Week.lines().forEach(aDataLine -> {
            var barData = aDataLine.split(",");
            var date = LocalDate.parse(barData[0], dtf).atStartOfDay(ZoneOffset.UTC).toInstant();
            var open = Double.parseDouble(barData[1]);
            var high = Double.parseDouble(barData[2]);
            var low = Double.parseDouble(barData[3]);
            var close = Double.parseDouble(barData[4]);
            var volume = Double.parseDouble(barData[6]);
            series1Weeks.barBuilder()
                    .endTime(date)
                    .openPrice(open)
                    .highPrice(high)
                    .lowPrice(low)
                    .closePrice(close)
                    .volume(volume)
                    .add();
        });
    }

    @Test
    public void PivotPointTestDailyBarCount() {
        var pp = new PivotPointIndicator(series5Minutes, DAY);
        var s1 = new StandardReversalIndicator(pp, SUPPORT_1);
        var s2 = new StandardReversalIndicator(pp, SUPPORT_2);
        var s3 = new StandardReversalIndicator(pp, SUPPORT_3);
        var r1 = new StandardReversalIndicator(pp, RESISTANCE_1);
        var r2 = new StandardReversalIndicator(pp, RESISTANCE_2);
        var r3 = new StandardReversalIndicator(pp, RESISTANCE_3);

        // pp
        assertEquals(NaN, pp.getValue(0));// first bar no data for calculation
        // result of calculation for 7-27 bar is not adequate because the previous day
        // is incomplete.
        assertNumEquals(Double.parseDouble("170.91666666666666"), pp.getValue(170));

        // prev last bar
        assertNumEquals(Double.parseDouble("169.20666666666666666666666666667"),
                pp.getValue(series5Minutes.getEndIndex() - 80));

        // last bar
        assertNumEquals(Double.parseDouble("170.07666666666666666666666666667"),
                pp.getValue(series5Minutes.getEndIndex()));

        // s1
        assertEquals(NaN, s1.getValue(0));
        assertNumEquals(Double.parseDouble("167.74333333333333333333333333334"),
                s1.getValue(series5Minutes.getEndIndex() - 80));
        assertNumEquals(Double.parseDouble("168.84333333333333333333333333334"),
                s1.getValue(series5Minutes.getEndIndex()));

        // s2
        assertEquals(NaN, s2.getValue(0));
        assertNumEquals(Double.parseDouble("166.82666666666666666666666666667"),
                s2.getValue(series5Minutes.getEndIndex() - 80));
        assertNumEquals(Double.parseDouble("167.36666666666666666666666666667"),
                s2.getValue(series5Minutes.getEndIndex()));

        // s3
        assertEquals(NaN, s3.getValue(0));
        assertNumEquals(Double.parseDouble("165.36333333333333333333333333334"),
                s3.getValue(series5Minutes.getEndIndex() - 80));
        assertNumEquals(Double.parseDouble("166.13333333333333333333333333334"),
                s3.getValue(series5Minutes.getEndIndex()));

        // r1
        assertEquals(NaN, r1.getValue(0));
        assertNumEquals(Double.parseDouble("170.12333333333333333333333333334"),
                r1.getValue(series5Minutes.getEndIndex() - 80));
        assertNumEquals(Double.parseDouble("171.55333333333333333333333333334"),
                r1.getValue(series5Minutes.getEndIndex()));

        // r2
        assertEquals(NaN, r2.getValue(0));
        assertNumEquals(Double.parseDouble("171.58666666666666666666666666667"),
                r2.getValue(series5Minutes.getEndIndex() - 80));
        assertNumEquals(Double.parseDouble("172.78666666666666666666666666667"),
                r2.getValue(series5Minutes.getEndIndex()));

        // r3
        assertEquals(NaN, r3.getValue(0));
        assertNumEquals(Double.parseDouble("172.50333333333333333333333333334"),
                r3.getValue(series5Minutes.getEndIndex() - 80));
        assertNumEquals(Double.parseDouble("174.26333333333333333333333333334"),
                r3.getValue(series5Minutes.getEndIndex()));

        var deMarkpp = new DeMarkPivotPointIndicator(series5Minutes, DAY);
        var deMarkR1 = new DeMarkReversalIndicator(deMarkpp, DeMarkReversalIndicator.DeMarkPivotLevel.RESISTANCE);
        var deMarkS1 = new DeMarkReversalIndicator(deMarkpp, DeMarkReversalIndicator.DeMarkPivotLevel.SUPPORT);
        assertNumEquals(deMarkpp.getValue(0), NaN);
        assertNumEquals(deMarkR1.getValue(0), NaN);
        assertNumEquals(deMarkS1.getValue(0), NaN);
        assertNumEquals(170.7875, deMarkpp.getValue(222));
        assertNumEquals(171.3250, deMarkR1.getValue(222));
        assertNumEquals(169.7050, deMarkS1.getValue(222));
        assertNumEquals(170.385, deMarkpp.getValue(series5Minutes.getEndIndex()));
        assertNumEquals(172.170, deMarkR1.getValue(series5Minutes.getEndIndex()));
        assertNumEquals(169.460, deMarkS1.getValue(series5Minutes.getEndIndex()));
    }

    @Test
    public void PivotPointTestWeeklyBarCount() {
        var pp = new PivotPointIndicator(series1Hours, TimeLevel.WEEK);

        assertEquals(NaN, pp.getValue(0));// first bar no data for
        assertEquals(NaN, pp.getValue(1));// first bar no data for calculation
        assertEquals(NaN, pp.getValue(6));// first bar no data for calculation
        // result of calculation for second bar is not adequate because the previous day
        // is incomplete
        assertNumEquals(Double.parseDouble("172.08166"), pp.getValue(28));
        assertNumEquals(Double.parseDouble("170.93666"), pp.getValue(series1Hours.getEndIndex() - 36)); // prev last bar
        assertNumEquals(Double.parseDouble("168.0100"), pp.getValue(series1Hours.getEndIndex())); // last bar

        var fibR3 = new FibonacciReversalIndicator(pp, 1, FibonacciReversalIndicator.FibReversalTyp.RESISTANCE);
        var fibR2 = new FibonacciReversalIndicator(pp, 0.618, FibonacciReversalIndicator.FibReversalTyp.RESISTANCE);
        var fibR1 = new FibonacciReversalIndicator(pp, 0.382, FibonacciReversalIndicator.FibReversalTyp.RESISTANCE);
        var fibS1 = new FibonacciReversalIndicator(pp, 0.382, FibonacciReversalIndicator.FibReversalTyp.SUPPORT);
        var fibS2 = new FibonacciReversalIndicator(pp, 0.618, FibonacciReversalIndicator.FibReversalTyp.SUPPORT);
        var fibS3 = new FibonacciReversalIndicator(pp, 1, FibonacciReversalIndicator.FibReversalTyp.SUPPORT);

        assertEquals(NaN, fibR3.getValue(series1Hours.getBeginIndex()));
        assertEquals(NaN, fibR2.getValue(1));
        assertEquals(NaN, fibR1.getValue(2));
        assertEquals(NaN, fibS1.getValue(6));
        assertEquals(NaN, fibS2.getValue(series1Hours.getBeginIndex()));
        assertEquals(NaN, fibS3.getValue(6));

        assertEquals(fibR3.getValue(series1Hours.getEndIndex()),
                pp.getValue(series1Hours.getEndIndex())
                        .plus(series1Hours.numFactory()
                                .one()
                                .multipliedBy(series1Hours.numFactory()
                                        .numOf(171.66)
                                        .minus(series1Hours.numFactory().numOf(161.56)))));
        assertEquals(fibR2.getValue(series1Hours.getEndIndex()),
                pp.getValue(series1Hours.getEndIndex())
                        .plus(series1Hours.numFactory()
                                .numOf(0.618)
                                .multipliedBy(series1Hours.numFactory()
                                        .numOf(171.66)
                                        .minus(series1Hours.numFactory().numOf(161.56)))));
        assertEquals(fibR1.getValue(series1Hours.getEndIndex()),
                pp.getValue(series1Hours.getEndIndex())
                        .plus(series1Hours.numFactory()
                                .numOf(0.382)
                                .multipliedBy(series1Hours.numFactory()
                                        .numOf(171.66)
                                        .minus(series1Hours.numFactory().numOf(161.56)))));
        assertEquals(fibS1.getValue(series1Hours.getEndIndex()),
                pp.getValue(series1Hours.getEndIndex())
                        .minus(series1Hours.numFactory()
                                .numOf(0.382)
                                .multipliedBy(series1Hours.numFactory()
                                        .numOf(171.66)
                                        .minus(series1Hours.numFactory().numOf(161.56)))));
        assertEquals(fibS2.getValue(series1Hours.getEndIndex()),
                pp.getValue(series1Hours.getEndIndex())
                        .minus(series1Hours.numFactory()
                                .numOf(0.618)
                                .multipliedBy(series1Hours.numFactory()
                                        .numOf(171.66)
                                        .minus(series1Hours.numFactory().numOf(161.56)))));
        assertEquals(fibS3.getValue(series1Hours.getEndIndex()),
                pp.getValue(series1Hours.getEndIndex())
                        .minus(series1Hours.numFactory()
                                .one()
                                .multipliedBy(series1Hours.numFactory()
                                        .numOf(171.66)
                                        .minus(series1Hours.numFactory().numOf(161.56)))));

        var deMarkpp = new DeMarkPivotPointIndicator(series1Hours, WEEK);
        var deMarkR1 = new DeMarkReversalIndicator(deMarkpp, DeMarkReversalIndicator.DeMarkPivotLevel.RESISTANCE);
        var deMarkS1 = new DeMarkReversalIndicator(deMarkpp, DeMarkReversalIndicator.DeMarkPivotLevel.SUPPORT);
        assertNumEquals(deMarkpp.getValue(0), NaN);
        assertNumEquals(deMarkR1.getValue(0), NaN);
        assertNumEquals(deMarkS1.getValue(0), NaN);
        assertNumEquals(170.5075, deMarkpp.getValue(series1Hours.getEndIndex() - 50));
        assertNumEquals(171.795, deMarkR1.getValue(series1Hours.getEndIndex() - 50));
        assertNumEquals(167.965, deMarkS1.getValue(series1Hours.getEndIndex() - 50));
        assertNumEquals(168.9225, deMarkpp.getValue(series1Hours.getEndIndex()));
        assertNumEquals(176.285, deMarkR1.getValue(series1Hours.getEndIndex()));
        assertNumEquals(166.185, deMarkS1.getValue(series1Hours.getEndIndex()));
    }

    @Test
    public void PivotPointTestMonthlyBarCount() {
        var pp = new PivotPointIndicator(series1Days, MONTH);
        var s1 = new StandardReversalIndicator(pp, SUPPORT_1);
        var s2 = new StandardReversalIndicator(pp, SUPPORT_2);
        var s3 = new StandardReversalIndicator(pp, SUPPORT_3);
        var r1 = new StandardReversalIndicator(pp, RESISTANCE_1);
        var r2 = new StandardReversalIndicator(pp, RESISTANCE_2);
        var r3 = new StandardReversalIndicator(pp, RESISTANCE_3);

        // pp
        assertEquals(NaN, pp.getValue(0));
        assertEquals(NaN, pp.getValue(19)); // no previous month for calculation
        assertNumEquals(Double.parseDouble("126.32333"), pp.getValue(20));
        assertNumEquals(Double.parseDouble("134.3415333"), pp.getValue(39));
        assertNumEquals(Double.parseDouble("150.67999"), pp.getValue(series1Days.getEndIndex() - 19));
        assertNumEquals(Double.parseDouble("164.18000"), pp.getValue(series1Days.getEndIndex()));

        // s1
        assertEquals(NaN, s1.getValue(0));
        assertEquals(NaN, s1.getValue(19)); // no previous month
        assertNumEquals(Double.parseDouble("144.8599999"), s1.getValue(series1Days.getEndIndex() - 19));
        assertNumEquals(Double.parseDouble("152.87"), s1.getValue(series1Days.getEndIndex()));

        // s2
        assertEquals(NaN, s2.getValue(0));
        assertEquals(NaN, s2.getValue(19)); // no previous month
        assertNumEquals(Double.parseDouble("138.73999999"), s2.getValue(series1Days.getEndIndex() - 19));
        assertNumEquals(Double.parseDouble("136.49000"), s2.getValue(series1Days.getEndIndex()));

        // s3
        assertEquals(NaN, s3.getValue(0));
        assertEquals(NaN, s3.getValue(19)); // no previous month
        assertNumEquals(Double.parseDouble("132.92"), s3.getValue(series1Days.getEndIndex() - 19));
        assertNumEquals(Double.parseDouble("125.18"), s3.getValue(series1Days.getEndIndex()));

        // r1
        assertEquals(NaN, r1.getValue(0));
        assertEquals(NaN, r1.getValue(19)); // no previous month
        assertNumEquals(Double.parseDouble("156.79999"), r1.getValue(series1Days.getEndIndex() - 19));
        assertNumEquals(Double.parseDouble("180.56000"), r1.getValue(series1Days.getEndIndex()));

        // r2
        assertEquals(NaN, r2.getValue(0));
        assertEquals(NaN, r2.getValue(19)); // no previous month
        assertNumEquals(Double.parseDouble("162.61999"), r2.getValue(series1Days.getEndIndex() - 19));
        assertNumEquals(Double.parseDouble("191.87000"), r2.getValue(series1Days.getEndIndex()));

        // r3
        assertEquals(NaN, r3.getValue(0));
        assertEquals(NaN, r3.getValue(19)); // no previous month
        assertNumEquals(Double.parseDouble("168.74"), r3.getValue(series1Days.getEndIndex() - 19));
        assertNumEquals(Double.parseDouble("208.25000"), r3.getValue(series1Days.getEndIndex()));
    }

    @Test
    public void PivotPointTestYearlyBarCount() {
        var pp = new PivotPointIndicator(series1Weeks, YEAR);
        var s1 = new StandardReversalIndicator(pp, SUPPORT_1);
        var s2 = new StandardReversalIndicator(pp, SUPPORT_2);
        var s3 = new StandardReversalIndicator(pp, SUPPORT_3);
        var r1 = new StandardReversalIndicator(pp, RESISTANCE_1);
        var r2 = new StandardReversalIndicator(pp, RESISTANCE_2);
        var r3 = new StandardReversalIndicator(pp, RESISTANCE_3);

        // pp
        assertEquals(NaN, pp.getValue(0));
        assertEquals(NaN, pp.getValue(33)); // no previous year
        assertNumEquals(Double.parseDouble("70.823331"), pp.getValue(series1Weeks.getEndIndex() - 100));
        assertNumEquals(Double.parseDouble("95.77000"), pp.getValue(series1Weeks.getEndIndex() - 40));
        assertNumEquals(Double.parseDouble("112.6400"), pp.getValue(series1Weeks.getEndIndex()));

        // s1
        assertEquals(NaN, s1.getValue(0));
        assertEquals(NaN, s1.getValue(33)); // no previous year
        assertNumEquals(Double.parseDouble("59.4766"), s1.getValue(series1Weeks.getEndIndex() - 100));
        assertNumEquals(Double.parseDouble("80.89000"), s1.getValue(series1Weeks.getEndIndex() - 40));
        assertNumEquals(Double.parseDouble("91.7800"), s1.getValue(series1Weeks.getEndIndex()));

        // s2
        assertEquals(NaN, s2.getValue(0));
        assertEquals(NaN, s2.getValue(33)); // no previous year
        assertNumEquals(Double.parseDouble("40.5033309"), s2.getValue(series1Weeks.getEndIndex() - 100));
        assertNumEquals(Double.parseDouble("57.11999999"), s2.getValue(series1Weeks.getEndIndex() - 40));
        assertNumEquals(Double.parseDouble("68.510004"), s2.getValue(series1Weeks.getEndIndex()));

        // s3
        assertEquals(NaN, s3.getValue(0));
        assertEquals(NaN, s3.getValue(33)); // no previous year
        assertNumEquals(Double.parseDouble("29.1566639"), s3.getValue(series1Weeks.getEndIndex() - 100));
        assertNumEquals(Double.parseDouble("42.239999"), s3.getValue(series1Weeks.getEndIndex() - 40));
        assertNumEquals(Double.parseDouble("47.65000"), s3.getValue(series1Weeks.getEndIndex()));

        // r1
        assertEquals(NaN, r1.getValue(0));
        assertEquals(NaN, r1.getValue(33)); // no previous year
        assertNumEquals(Double.parseDouble("89.7966640"), r1.getValue(series1Weeks.getEndIndex() - 100));
        assertNumEquals(Double.parseDouble("119.5400"), r1.getValue(series1Weeks.getEndIndex() - 40));
        assertNumEquals(Double.parseDouble("135.91000"), r1.getValue(series1Weeks.getEndIndex()));

        // r2
        assertEquals(NaN, r2.getValue(0));
        assertEquals(NaN, r2.getValue(33)); // no previous year
        assertNumEquals(Double.parseDouble("101.1433310"), r2.getValue(series1Weeks.getEndIndex() - 100));
        assertNumEquals(Double.parseDouble("134.42000"), r2.getValue(series1Weeks.getEndIndex() - 40));
        assertNumEquals(Double.parseDouble("156.76999"), r2.getValue(series1Weeks.getEndIndex()));

        // r3
        assertEquals(NaN, r3.getValue(0));
        assertEquals(NaN, r3.getValue(33)); // no previous year
        assertNumEquals(Double.parseDouble("120.116664"), r3.getValue(series1Weeks.getEndIndex() - 100));
        assertNumEquals(Double.parseDouble("158.19000"), r3.getValue(series1Weeks.getEndIndex() - 40));
        assertNumEquals(Double.parseDouble("180.03999"), r3.getValue(series1Weeks.getEndIndex()));
    }

    @Test
    public void shouldIncludeBarAtBeginIndexInPreviousPeriod() {
        // Create a series where the bar at beginIndex (index 0) is in the previous
        // period
        // This tests the boundary condition fix where >= is used instead of >
        var series = new MockBarSeriesBuilder().withName("BoundaryTest").build();

        // Day 1 (previous period) - this bar is at beginIndex
        series.barBuilder()
                .endTime(LocalDate.parse("2024-01-01").atStartOfDay(ZoneOffset.UTC).toInstant())
                .openPrice(100.0)
                .highPrice(105.0)
                .lowPrice(95.0)
                .closePrice(102.0)
                .volume(1000)
                .add();

        // Day 2 (current period) - pivot point calculation should include Day 1 bar
        series.barBuilder()
                .endTime(LocalDate.parse("2024-01-02").atStartOfDay(ZoneOffset.UTC).toInstant())
                .openPrice(102.0)
                .highPrice(108.0)
                .lowPrice(100.0)
                .closePrice(106.0)
                .volume(1200)
                .add();

        // Day 2 continuation (same period)
        series.barBuilder()
                .endTime(LocalDate.parse("2024-01-02").atTime(12, 0).atZone(ZoneOffset.UTC).toInstant())
                .openPrice(106.0)
                .highPrice(110.0)
                .lowPrice(104.0)
                .closePrice(108.0)
                .volume(800)
                .add();

        var pp = new PivotPointIndicator(series, DAY);
        var deMarkpp = new DeMarkPivotPointIndicator(series, DAY);

        // At index 0 (Day 1), no previous period exists
        assertEquals(NaN, pp.getValue(0));
        assertEquals(NaN, deMarkpp.getValue(0));

        // At index 1 (first bar of Day 2), should include Day 1 bar in previous period
        // PivotPoint: (high + low + close) / 3 = (105 + 95 + 102) / 3 = 302 / 3 =
        // 100.666...
        assertNumEquals(100.66666666666667, pp.getValue(1));

        // DeMarkPivotPoint: Uses open from first bar of previous period (100.0)
        // close (102) < open (100) is false, close (102) > open (100) is true
        // Formula: (2 * high + low + close) / 4 = (2 * 105 + 95 + 102) / 4 = 407 / 4 =
        // 101.75
        assertNumEquals(101.75, deMarkpp.getValue(1));

        // Verify that the bar at beginIndex (index 0) is included in the previous
        // period
        var barsOfPreviousPeriod = pp.getBarsOfPreviousPeriod(1);
        assertEquals(1, barsOfPreviousPeriod.size());
        assertEquals(0, barsOfPreviousPeriod.get(0).intValue()); // Should include index 0

        var deMarkBarsOfPreviousPeriod = deMarkpp.getBarsOfPreviousPeriod(1);
        assertEquals(1, deMarkBarsOfPreviousPeriod.size());
        assertEquals(0, deMarkBarsOfPreviousPeriod.get(0).intValue()); // Should include index 0

        // At index 2 (second bar of Day 2), should still include Day 1 bar in previous
        // period
        assertNumEquals(100.66666666666667, pp.getValue(2));
        assertNumEquals(101.75, deMarkpp.getValue(2));
    }

    @Test
    public void shouldTreatBeginIndexBarAsCurrentPeriodBoundary() {
        var series = new MockBarSeriesBuilder().withName("BeginBoundaryGuard").build();

        // Both bars are in the same day; beginIndex bar must be considered when
        // stepping back through the current period
        series.barBuilder()
                .endTime(LocalDate.parse("2024-02-01").atStartOfDay(ZoneOffset.UTC).toInstant())
                .openPrice(100.0)
                .highPrice(105.0)
                .lowPrice(95.0)
                .closePrice(102.0)
                .volume(1000)
                .add();
        series.barBuilder()
                .endTime(LocalDate.parse("2024-02-01").atTime(12, 0).atZone(ZoneOffset.UTC).toInstant())
                .openPrice(102.0)
                .highPrice(108.0)
                .lowPrice(100.0)
                .closePrice(106.0)
                .volume(1200)
                .add();

        var indicator = new GuardedPivotPointIndicator(series, DAY);
        var barsOfPreviousPeriod = indicator.getBarsOfPreviousPeriod(1);
        assertEquals(0, barsOfPreviousPeriod.size());
    }

    @Test
    public void shouldHandleBeginIndexGreaterThanZero() {
        // Create a series with multiple days
        var series = new MockBarSeriesBuilder().withName("BeginIndexTest").build();

        // Day 1
        series.barBuilder()
                .endTime(LocalDate.parse("2024-01-01").atStartOfDay(ZoneOffset.UTC).toInstant())
                .openPrice(100.0)
                .highPrice(105.0)
                .lowPrice(95.0)
                .closePrice(102.0)
                .volume(1000)
                .add();

        // Day 2
        series.barBuilder()
                .endTime(LocalDate.parse("2024-01-02").atStartOfDay(ZoneOffset.UTC).toInstant())
                .openPrice(102.0)
                .highPrice(108.0)
                .lowPrice(100.0)
                .closePrice(106.0)
                .volume(1200)
                .add();

        // Day 3
        series.barBuilder()
                .endTime(LocalDate.parse("2024-01-03").atStartOfDay(ZoneOffset.UTC).toInstant())
                .openPrice(106.0)
                .highPrice(110.0)
                .lowPrice(104.0)
                .closePrice(108.0)
                .volume(800)
                .add();

        // Day 4
        series.barBuilder()
                .endTime(LocalDate.parse("2024-01-04").atStartOfDay(ZoneOffset.UTC).toInstant())
                .openPrice(108.0)
                .highPrice(112.0)
                .lowPrice(106.0)
                .closePrice(110.0)
                .volume(900)
                .add();

        // Set maximum bar count to 2, which will set beginIndex to 2
        // This means the series will only contain bars at indices 2 and 3
        series.setMaximumBarCount(2);

        // Verify beginIndex is now 2
        assertEquals(2, series.getBeginIndex());
        assertEquals(3, series.getEndIndex());

        var pp = new PivotPointIndicator(series, DAY);
        var deMarkpp = new DeMarkPivotPointIndicator(series, DAY);

        // At beginIndex (index 2), there's no previous period, so should return NaN
        // This tests the fix: when index == beginIndex > 0, it should return early
        // without trying to access index - 1
        assertEquals(NaN, pp.getValue(series.getBeginIndex()));
        assertEquals(NaN, deMarkpp.getValue(series.getBeginIndex()));

        // Verify getBarsOfPreviousPeriod returns empty list at beginIndex
        var barsOfPreviousPeriod = pp.getBarsOfPreviousPeriod(series.getBeginIndex());
        assertEquals(0, barsOfPreviousPeriod.size());

        // At index 3 (first bar after beginIndex), should include Day 3 bar in previous
        // period
        // Day 3: (110 + 104 + 108) / 3 = 322 / 3 = 107.333...
        assertNumEquals(107.33333333333333, pp.getValue(3));
    }

    /**
     * Testable subclass that exposes the protected getPreviousPeriod method for
     * testing.
     */
    private static class TestablePivotPointIndicator extends AbstractPivotPointIndicator {
        public TestablePivotPointIndicator(BarSeries series, TimeLevel timeLevel) {
            super(series, timeLevel);
        }

        @Override
        protected Num calcPivotPoint(List<Integer> barsOfPreviousPeriod) {
            // Not used in these tests
            return null;
        }

        public long getPreviousPeriodForTesting(Bar bar, int indexOfPreviousBar) {
            return getPreviousPeriod(bar, indexOfPreviousBar);
        }
    }

    private static final class GuardedPivotPointIndicator extends TestablePivotPointIndicator {
        public GuardedPivotPointIndicator(BarSeries series, TimeLevel timeLevel) {
            super(series, timeLevel);
        }

        @Override
        protected long getPreviousPeriod(Bar bar, int indexOfPreviousBar) {
            if (indexOfPreviousBar >= getBarSeries().getBeginIndex()) {
                var previousBar = getBarSeries().getBar(indexOfPreviousBar);
                assertFalse("Expected beginIndex bar to be treated as part of the current period boundary",
                        getPeriod(previousBar) == getPeriod(bar));
            }
            return super.getPreviousPeriod(bar, indexOfPreviousBar);
        }
    }

    @Test
    public void shouldSkipWeekendWhenFindingPreviousDay() {
        // Create a series: Friday (2024-01-05), then Monday (2024-01-08)
        // Day of year: Friday = 5, Saturday = 6, Sunday = 7, Monday = 8
        var series = new MockBarSeriesBuilder().withName("WeekendTest").build();

        // Friday, January 5, 2024 (day of year: 5)
        series.barBuilder()
                .endTime(LocalDate.parse("2024-01-05").atStartOfDay(ZoneOffset.UTC).toInstant())
                .openPrice(100.0)
                .highPrice(105.0)
                .lowPrice(95.0)
                .closePrice(102.0)
                .volume(1000)
                .add();

        // Monday, January 8, 2024 (day of year: 8)
        series.barBuilder()
                .endTime(LocalDate.parse("2024-01-08").atStartOfDay(ZoneOffset.UTC).toInstant())
                .openPrice(102.0)
                .highPrice(108.0)
                .lowPrice(100.0)
                .closePrice(106.0)
                .volume(1200)
                .add();

        var indicator = new TestablePivotPointIndicator(series, DAY);
        var mondayBar = series.getBar(1);
        var fridayIndex = 0;

        // When asking for previous period of Monday (day 8), should return Friday (day
        // 5)
        // The loop should skip Saturday (6) and Sunday (7) and find Friday (5)
        long previousPeriod = indicator.getPreviousPeriodForTesting(mondayBar, fridayIndex);
        assertEquals(5L, previousPeriod);
    }

    @Test
    public void shouldSkipHolidayWhenFindingPreviousDay() {
        // Create a series: Monday (2024-01-01), then Wednesday (2024-01-03)
        // Day of year: Monday = 1, Tuesday = 2 (holiday), Wednesday = 3
        var series = new MockBarSeriesBuilder().withName("HolidayTest").build();

        // Monday, January 1, 2024 (day of year: 1)
        series.barBuilder()
                .endTime(LocalDate.parse("2024-01-01").atStartOfDay(ZoneOffset.UTC).toInstant())
                .openPrice(100.0)
                .highPrice(105.0)
                .lowPrice(95.0)
                .closePrice(102.0)
                .volume(1000)
                .add();

        // Wednesday, January 3, 2024 (day of year: 3)
        series.barBuilder()
                .endTime(LocalDate.parse("2024-01-03").atStartOfDay(ZoneOffset.UTC).toInstant())
                .openPrice(102.0)
                .highPrice(108.0)
                .lowPrice(100.0)
                .closePrice(106.0)
                .volume(1200)
                .add();

        var indicator = new TestablePivotPointIndicator(series, DAY);
        var wednesdayBar = series.getBar(1);
        var mondayIndex = 0;

        // When asking for previous period of Wednesday (day 3), should return Monday
        // (day 1)
        // The loop should skip Tuesday (2) and find Monday (1)
        long previousPeriod = indicator.getPreviousPeriodForTesting(wednesdayBar, mondayIndex);
        assertEquals(1L, previousPeriod);
    }

    @Test
    public void shouldSkipMultipleGapsWhenFindingPreviousDay() {
        // Create a series: Wednesday (2024-01-03), then Monday (2024-01-08)
        // Day of year: Wed = 3, Thu = 4, Fri = 5, Sat = 6, Sun = 7, Mon = 8
        var series = new MockBarSeriesBuilder().withName("MultipleGapsTest").build();

        // Wednesday, January 3, 2024 (day of year: 3)
        series.barBuilder()
                .endTime(LocalDate.parse("2024-01-03").atStartOfDay(ZoneOffset.UTC).toInstant())
                .openPrice(100.0)
                .highPrice(105.0)
                .lowPrice(95.0)
                .closePrice(102.0)
                .volume(1000)
                .add();

        // Monday, January 8, 2024 (day of year: 8)
        series.barBuilder()
                .endTime(LocalDate.parse("2024-01-08").atStartOfDay(ZoneOffset.UTC).toInstant())
                .openPrice(102.0)
                .highPrice(108.0)
                .lowPrice(100.0)
                .closePrice(106.0)
                .volume(1200)
                .add();

        var indicator = new TestablePivotPointIndicator(series, DAY);
        var mondayBar = series.getBar(1);
        var wednesdayIndex = 0;

        // When asking for previous period of Monday (day 8), should return Wednesday
        // (day 3)
        // The loop should skip Thu (4), Fri (5), Sat (6), Sun (7) and find Wed (3)
        long previousPeriod = indicator.getPreviousPeriodForTesting(mondayBar, wednesdayIndex);
        assertEquals(3L, previousPeriod);
    }

    @Test
    public void shouldHandleConsecutiveDaysCorrectly() {
        // Create a series with consecutive trading days: Mon, Tue, Wed
        var series = new MockBarSeriesBuilder().withName("ConsecutiveDaysTest").build();

        // Monday, January 1, 2024 (day of year: 1)
        series.barBuilder()
                .endTime(LocalDate.parse("2024-01-01").atStartOfDay(ZoneOffset.UTC).toInstant())
                .openPrice(100.0)
                .highPrice(105.0)
                .lowPrice(95.0)
                .closePrice(102.0)
                .volume(1000)
                .add();

        // Tuesday, January 2, 2024 (day of year: 2)
        series.barBuilder()
                .endTime(LocalDate.parse("2024-01-02").atStartOfDay(ZoneOffset.UTC).toInstant())
                .openPrice(102.0)
                .highPrice(108.0)
                .lowPrice(100.0)
                .closePrice(106.0)
                .volume(1200)
                .add();

        // Wednesday, January 3, 2024 (day of year: 3)
        series.barBuilder()
                .endTime(LocalDate.parse("2024-01-03").atStartOfDay(ZoneOffset.UTC).toInstant())
                .openPrice(106.0)
                .highPrice(110.0)
                .lowPrice(104.0)
                .closePrice(108.0)
                .volume(800)
                .add();

        var indicator = new TestablePivotPointIndicator(series, DAY);
        var wednesdayBar = series.getBar(2);
        var tuesdayIndex = 1;

        // When asking for previous period of Wednesday (day 3), should return Tuesday
        // (day 2)
        // No gaps, so should match immediately
        long previousPeriod = indicator.getPreviousPeriodForTesting(wednesdayBar, tuesdayIndex);
        assertEquals(2L, previousPeriod);
    }

    @Test
    public void shouldUpdatePreviousZonedEndTimeOnEachIteration() {
        // This test specifically verifies the bug fix: previousZonedEndTime must be
        // updated on each loop iteration, not just once before the loop.
        // Create a series: Friday, then Monday (weekend gap)
        var series = new MockBarSeriesBuilder().withName("StaleVariableFixTest").build();

        // Friday, January 5, 2024 (day of year: 5)
        series.barBuilder()
                .endTime(LocalDate.parse("2024-01-05").atStartOfDay(ZoneOffset.UTC).toInstant())
                .openPrice(100.0)
                .highPrice(105.0)
                .lowPrice(95.0)
                .closePrice(102.0)
                .volume(1000)
                .add();

        // Monday, January 8, 2024 (day of year: 8)
        series.barBuilder()
                .endTime(LocalDate.parse("2024-01-08").atStartOfDay(ZoneOffset.UTC).toInstant())
                .openPrice(102.0)
                .highPrice(108.0)
                .lowPrice(100.0)
                .closePrice(106.0)
                .volume(1200)
                .add();

        var indicator = new TestablePivotPointIndicator(series, DAY);
        var mondayBar = series.getBar(1);
        var fridayIndex = 0;

        // The bug was that previousZonedEndTime was fetched once before the loop
        // and never updated. With the fix, it should be fetched on each iteration.
        // When prevCalendarDay starts at 7 (Sunday), it should check the bar at
        // fridayIndex (which is day 5), see it doesn't match, decrement to 6,
        // check again (still doesn't match), decrement to 5, and then match.
        // This verifies that previousZonedEndTime is being re-fetched correctly.
        long previousPeriod = indicator.getPreviousPeriodForTesting(mondayBar, fridayIndex);
        assertEquals(5L, previousPeriod);
    }

    @Test
    public void shouldHandleYearBoundaryCorrectly() {
        // Test edge case: previous day crosses year boundary
        // December 31, 2023 -> January 1, 2024
        var series = new MockBarSeriesBuilder().withName("YearBoundaryTest").build();

        // December 31, 2023 (day of year: 365)
        series.barBuilder()
                .endTime(LocalDate.parse("2023-12-31").atStartOfDay(ZoneOffset.UTC).toInstant())
                .openPrice(100.0)
                .highPrice(105.0)
                .lowPrice(95.0)
                .closePrice(102.0)
                .volume(1000)
                .add();

        // January 1, 2024 (day of year: 1)
        series.barBuilder()
                .endTime(LocalDate.parse("2024-01-01").atStartOfDay(ZoneOffset.UTC).toInstant())
                .openPrice(102.0)
                .highPrice(108.0)
                .lowPrice(100.0)
                .closePrice(106.0)
                .volume(1200)
                .add();

        var indicator = new TestablePivotPointIndicator(series, DAY);
        var januaryBar = series.getBar(1);
        var decemberIndex = 0;

        // When asking for previous period of January 1 (day 1), should return December
        // 31 (day 365)
        // Note: The method uses day of year, so it should correctly handle the year
        // boundary
        long previousPeriod = indicator.getPreviousPeriodForTesting(januaryBar, decemberIndex);
        assertEquals(365L, previousPeriod);
    }
}
